Add BAAT catalogue#177
Conversation
🦋 Changeset detectedLatest commit: c0422ac The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis update introduces support for the "baat" fertilizer catalogue throughout the system. It adds the "baat" dataset, enables its selection and syncing, updates relevant types, documentation, and tests, and extends form handling to support new fertilizer parameters. Existing logic is adapted to accommodate this new catalogue source. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App (fdm-app)
participant Core (fdm-core)
participant Data (fdm-data)
Note over User: Creates new farm or requests fertilizer catalogue
User->>App (fdm-app): Initiate farm creation or fetch fertilizers
App (fdm-app)->>Core (fdm-core): enableFertilizerCatalogue("baat")
App (fdm-app)->>Data (fdm-data): getFertilizersCatalogue("baat")
Data (fdm-data)->>Data (fdm-data): getCatalogueBaat()
Data (fdm-data)->>Data (fdm-data): Load and hash baat.json entries
Data (fdm-data)-->>App (fdm-app): Return baat catalogue
App (fdm-app)-->>User: Show catalogue/fertilizer options
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## development #177 +/- ##
===============================================
+ Coverage 93.45% 93.49% +0.04%
===============================================
Files 73 74 +1
Lines 8784 8872 +88
Branches 1088 1120 +32
===============================================
+ Hits 8209 8295 +86
- Misses 573 575 +2
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
fdm-data/src/fertilizers/index.test.ts (1)
21-21: Improve type assertion to address static analysis warningThe
as anytype assertion triggers a linting warning. Consider using a more specific type assertion for better type safety.- getFertilizersCatalogue("invalid-catalogue" as any), + getFertilizersCatalogue("invalid-catalogue" as CatalogueFertilizerName),This maintains the same testing behavior while being more explicit about the type violation being tested.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
.changeset/lucky-candies-push.md(1 hunks).changeset/tame-jokes-enjoy.md(1 hunks).changeset/witty-areas-decide.md(1 hunks)fdm-app/app/routes/farm.$b_id_farm.fertilizers.$p_id.tsx(1 hunks)fdm-app/app/routes/farm.$b_id_farm.fertilizers.new.$p_id.tsx(3 hunks)fdm-app/app/routes/farm.$b_id_farm.fertilizers.new.custom.tsx(5 hunks)fdm-app/app/routes/farm.create._index.tsx(1 hunks)fdm-core/src/catalogues.ts(1 hunks)fdm-data/README.md(1 hunks)fdm-data/src/fertilizers/catalogues/baat.json(1 hunks)fdm-data/src/fertilizers/catalogues/baat.ts(1 hunks)fdm-data/src/fertilizers/d.ts(1 hunks)fdm-data/src/fertilizers/index.test.ts(4 hunks)fdm-data/src/fertilizers/index.ts(3 hunks)fdm-docs/docs/core-concepts/02-schema.md(1 hunks)fdm-docs/docs/core-concepts/03-catalogues.md(2 hunks)fdm-docs/docs/getting-started/04-using-catalogues-fdm-data.md(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
fdm-core/src/catalogues.ts (2)
fdm-data/src/fertilizers/index.ts (1)
getFertilizersCatalogue(25-36)fdm-core/src/db/schema.ts (1)
fertilizersCatalogue(187-247)
fdm-data/src/fertilizers/index.ts (1)
fdm-data/src/fertilizers/catalogues/baat.ts (1)
getCatalogueBaat(19-102)
fdm-data/src/fertilizers/catalogues/baat.ts (1)
fdm-data/src/fertilizers/d.ts (3)
CatalogueFertilizer(70-70)CatalogueFertilizerItem(15-68)ApplicationMethods(3-13)
🪛 LanguageTool
.changeset/tame-jokes-enjoy.md
[uncategorized] ~5-~5: Possible missing comma found.
Context: ...- "@svenvw/fdm-app": minor --- For new farms use the baat catalogue for fertilizer...
(AI_HYDRA_LEO_MISSING_COMMA)
🪛 GitHub Check: codecov/patch
fdm-data/src/fertilizers/catalogues/baat.ts
[warning] 29-29: fdm-data/src/fertilizers/catalogues/baat.ts#L29
Added line #L29 was not covered by tests
[warning] 36-36: fdm-data/src/fertilizers/catalogues/baat.ts#L36
Added line #L36 was not covered by tests
🪛 Biome (1.9.4)
fdm-data/src/fertilizers/index.test.ts
[error] 21-21: Unexpected any. Specify a different type.
any disables many type checking rules. Its use should be avoided.
(lint/suspicious/noExplicitAny)
🔇 Additional comments (23)
.changeset/witty-areas-decide.md (1)
1-6: LGTM! Clear and concise changeset documentation.The changeset correctly documents the addition of the new
baatfertilizer catalogue as a minor version update to the@svenvw/fdm-datapackage..changeset/tame-jokes-enjoy.md (1)
5-6: Verify impact of changing default fertilizer catalogue.The changeset documents switching new farms from
srmtobaatcatalogue. While this appears intentional based on the broader PR context, ensure this change won't break existing integrations or workflows that might expectsrmas the default catalogue..changeset/lucky-candies-push.md (1)
1-6: LGTM! Appropriate infrastructure change documented.The changeset correctly documents the addition of syncing functionality for the new
baatfertilizer catalogue in the core package.fdm-app/app/routes/farm.create._index.tsx (1)
206-207: ```shell
#!/bin/bash
echo "Scanning fdm-app for 'srm' references..."
rg -n -i --glob '.ts' --glob '.tsx' 'srm' fdm-app/echo -e "\nScanning fdm-app for 'baat' references..."
rg -n -i --glob '.ts' --glob '.tsx' 'baat' fdm-app/echo -e "\nScanning fdm-app for 'getFertilizersFromCatalogue' usage..."
rg -n --glob '.ts' --glob '.tsx' 'getFertilizersFromCatalogue' fdm-app/</details> <details> <summary>fdm-data/README.md (1)</summary> `30-34`: **LGTM! Documentation examples properly updated.** The README example has been consistently updated to use the new `"baat"` catalogue instead of `"srm"`, including the variable names, comments, and console output message. This ensures the documentation reflects the current default behavior. </details> <details> <summary>fdm-app/app/routes/farm.$b_id_farm.fertilizers.$p_id.tsx (1)</summary> `164-165`: **LGTM: New fertilizer parameters added correctly.** The addition of `p_no3_rt` and `p_nh4_rt` parameters follows the existing pattern and is positioned logically among other nitrogen-related parameters. </details> <details> <summary>fdm-docs/docs/getting-started/04-using-catalogues-fdm-data.md (1)</summary> `20-20`: **LGTM: Documentation updated to use BAAT catalogue.** The import and console log changes correctly reflect the switch from SRM to BAAT fertilizer catalogue. Also applies to: 24-24 </details> <details> <summary>fdm-docs/docs/core-concepts/02-schema.md (1)</summary> `247-247`: **LGTM: Schema documentation aligned with implementation.** The change from uppercase to lowercase example values correctly reflects the actual type definition that uses lowercase strings. </details> <details> <summary>fdm-data/src/fertilizers/d.ts (1)</summary> `1-1`: **LGTM: Type definition correctly extended for BAAT catalogue.** The union type addition is backward compatible and properly enables support for the new "baat" fertilizer catalogue source. </details> <details> <summary>fdm-docs/docs/core-concepts/03-catalogues.md (1)</summary> `26-26`: **LGTM: Documentation updated to include BAAT catalogue.** The additions correctly recognize "baat" as a valid source identifier and update examples to reflect the new fertilizer catalogue integration. Also applies to: 41-41 </details> <details> <summary>fdm-core/src/catalogues.ts (1)</summary> `380-382`: **LGTM: Clean implementation of multi-catalogue support** The implementation correctly fetches both "srm" and "baat" catalogues and combines them using the spread operator. This maintains the existing transaction logic while extending functionality to support multiple fertilizer data sources. </details> <details> <summary>fdm-app/app/routes/farm.$b_id_farm.fertilizers.new.$p_id.tsx (1)</summary> `159-160`: **LGTM: Consistent addition of nitrate and ammonium parameters** The new fertilizer parameters `p_no3_rt` and `p_nh4_rt` are correctly added to both form defaults and action data, maintaining consistency between UI and backend processing. These parameters enhance the fertilizer data model for better agricultural management. Also applies to: 241-242 </details> <details> <summary>fdm-data/src/fertilizers/index.ts (1)</summary> `1-1`: **LGTM: Clean extension of catalogue dispatcher** The implementation correctly adds "baat" catalogue support following the same pattern as the existing "srm" catalogue. The documentation update and import addition are appropriate, and error handling remains robust. Also applies to: 12-12, 32-34 </details> <details> <summary>fdm-data/src/fertilizers/catalogues/baat.ts (1)</summary> `19-102`: **LGTM: Well-implemented catalogue loader with proper data transformation** The `getCatalogueBaat` function is well-structured with proper: - Async processing using `Promise.all` for performance - Null handling for undefined JSON properties - String splitting for application methods - Type safety with explicit `CatalogueFertilizerItem` interface - Hash generation for data integrity The static analysis warnings about test coverage on conditional branches (lines 29, 36) are acceptable as they handle edge cases for undefined values. </details> <details> <summary>fdm-data/src/fertilizers/index.test.ts (2)</summary> `3-3`: **LGTM: Comprehensive test coverage for BAAT catalogue** The test additions provide excellent coverage for the new "baat" catalogue functionality, including validation of catalogue retrieval, non-empty results, and correct source attribution. The tests follow the established patterns and ensure the new catalogue works correctly. Also applies to: 13-17, 31-35, 44-49 --- `119-184`: **LGTM: Thorough property validation for BAAT catalogue items** The comprehensive test validates all expected properties of `CatalogueFertilizerItem` objects returned by `getCatalogueBaat`, ensuring data structure integrity and type conformance. </details> <details> <summary>fdm-app/app/routes/farm.$b_id_farm.fertilizers.new.custom.tsx (4)</summary> `76-77`: **LGTM! Consistent parameter addition.** The new nitrogen parameters `p_no3_rt` and `p_nh4_rt` are properly initialized following the established pattern for fertilizer properties. --- `161-162`: **LGTM! Form default values properly updated.** The new parameters are correctly included in the form's default values, maintaining consistency with the loader data structure. --- `211-212`: **LGTM! Form reset logic updated correctly.** The new parameters are properly included in the form reset logic, ensuring consistent form state management when fertilizer data changes. --- `288-289`: **Verify the `p_ef_nh3` parameter handling.** The new nitrogen parameters `p_no3_rt` and `p_nh4_rt` are correctly extracted from form values. However, `p_ef_nh3` is only added in the action handler (line 314) but doesn't appear in the loader, form defaults, or form reset logic. Please verify this is intentional. ```shell #!/bin/bash # Description: Check if p_ef_nh3 is handled elsewhere in the codebase or if it's a backend-computed field # Search for p_ef_nh3 usage across the codebase echo "=== Searching for p_ef_nh3 usage ===" rg -A 3 -B 3 "p_ef_nh3" # Check if p_ef_nh3 appears in form schemas echo "=== Checking form schemas ===" fd -e ts -e tsx -e js -e jsx | xargs rg -l "FormSchema\|formschema" | xargs rg -A 10 -B 5 "p_ef_nh3" # Check fertilizer parameter descriptions echo "=== Checking fertilizer parameter descriptions ===" rg -A 5 -B 5 "getFertilizerParametersDescription\|ParametersDescription"Also applies to: 314-314
fdm-data/src/fertilizers/catalogues/baat.json (3)
1-100: LGTM! Well-structured fertilizer catalog data.The JSON structure is consistent and well-organized with:
- Systematic ID scheme (BAAT001, BAAT002, etc.)
- Consistent property naming and data types
- Proper use of
nullfor missing values- Clear source attribution ("baat")
18-21: LGTM! Nitrogen speciation data is chemically consistent.The new nitrogen parameters
p_no3_rtandp_nh4_rtshow chemically sound relationships with total inorganic nitrogen (p_n_if). For example, in ammonium nitrate (BAAT002), the nitrate and ammonium values sum to the total inorganic nitrogen (170+170=340), which is expected for this fertilizer type.Also applies to: 58-61, 98-101
37-40: LGTM! Application methods and type classifications are agriculturally sound.The application methods are appropriately matched to fertilizer types:
- Solid mineral fertilizers: broadcasting, pocket placement, incorporation
- Liquid fertilizers: spoke wheel, spraying
- Manures: various injection and incorporation methods
Type classifications are mutually exclusive and correctly applied.
Also applies to: 117-120, 397-400
Summary by CodeRabbit
New Features
Improvements
Documentation
Tests