Conversation
There was a problem hiding this comment.
Pull request overview
This pull request expands the Nutriments struct within the Product type to include a more comprehensive set of nutritional fields. The changes replace a minimal set of 33 nutrient fields with an expanded set of 65 fields, adding support for various fat types (saturated, monounsaturated, polyunsaturated, trans), sodium/salt measurements, nova groups, nutrition scores, and fruit/vegetable estimates.
Changes:
- Replaced all fields in the
Nutrimentsstruct with an expanded and reorganized set of nutritional data fields - Changed several field types from
inttofloat64for better precision in nutritional data - Removed sugar-specific fields (
Sugars,SugarsValue,SugarsUnit,Sugars100G,SugarsServing) which may be a breaking change - Added new fields for trans fats, polyunsaturated fats, monounsaturated fats, saturated fats, salt, sodium, nova groups, and nutrition scores
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -296,37 +296,71 @@ type Product struct { | |||
| TracesTags []interface{} `json:"traces_tags" bson:"traces_tags,truncate"` | |||
| Rev int `json:"rev" bson:"rev,truncate"` | |||
| Nutriments struct { | |||
There was a problem hiding this comment.
The removal of sugar-related fields (Sugars, SugarsValue, SugarsUnit, Sugars100G, SugarsServing) from the Nutriments struct represents a breaking API change. If these fields are used by API consumers or exist in the database, their removal could cause data loss or runtime errors during JSON/BSON deserialization. Consider either retaining these fields alongside the new ones, or verify that these fields are not present in the actual data source and are not consumed by any clients.
| EnergyKcalValue float64 `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"` | ||
| MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"` | ||
| FatValue float64 `json:"fat_value" bson:"fat_value,truncate"` | ||
| FruitsVegetablesLegumesEstimateFromIngredientsServing float64 `json:"fruits-vegetables-legumes-estimate-from-ingredients_serving" bson:"fruits-vegetables-legumes-estimate-from-ingredients_serving,truncate"` | ||
| ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"` | ||
| TransFatValue float64 `json:"trans-fat_value" bson:"trans-fat_value,truncate"` | ||
| FruitsVegetablesNutsEstimateFromIngredientsServing float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_serving" bson:"fruits-vegetables-nuts-estimate-from-ingredients_serving,truncate"` | ||
| EnergyServing float64 `json:"energy_serving" bson:"energy_serving,truncate"` | ||
| SaturatedFatValue float64 `json:"saturated-fat_value" bson:"saturated-fat_value,truncate"` | ||
| ProteinsUnit string `json:"proteins_unit" bson:"proteins_unit"` | ||
| Salt float64 `json:"salt" bson:"salt,truncate"` | ||
| Carbohydrates float64 `json:"carbohydrates" bson:"carbohydrates,truncate"` | ||
| Salt100g float64 `json:"salt_100g" bson:"salt_100g,truncate"` |
There was a problem hiding this comment.
Field type changed from int to float64 for energy-related fields. While this provides better precision, it's a breaking change if clients are expecting integer values in JSON responses. Verify that downstream consumers can handle decimal values for these fields.
| EnergyKcalValue float64 `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"` | |
| MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"` | |
| FatValue float64 `json:"fat_value" bson:"fat_value,truncate"` | |
| FruitsVegetablesLegumesEstimateFromIngredientsServing float64 `json:"fruits-vegetables-legumes-estimate-from-ingredients_serving" bson:"fruits-vegetables-legumes-estimate-from-ingredients_serving,truncate"` | |
| ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"` | |
| TransFatValue float64 `json:"trans-fat_value" bson:"trans-fat_value,truncate"` | |
| FruitsVegetablesNutsEstimateFromIngredientsServing float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_serving" bson:"fruits-vegetables-nuts-estimate-from-ingredients_serving,truncate"` | |
| EnergyServing float64 `json:"energy_serving" bson:"energy_serving,truncate"` | |
| SaturatedFatValue float64 `json:"saturated-fat_value" bson:"saturated-fat_value,truncate"` | |
| ProteinsUnit string `json:"proteins_unit" bson:"proteins_unit"` | |
| Salt float64 `json:"salt" bson:"salt,truncate"` | |
| Carbohydrates float64 `json:"carbohydrates" bson:"carbohydrates,truncate"` | |
| Salt100g float64 `json:"salt_100g" bson:"salt_100g,truncate"` | |
| EnergyKcalValue int `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"` | |
| MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"` | |
| FatValue float64 `json:"fat_value" bson:"fat_value,truncate"` | |
| FruitsVegetablesLegumesEstimateFromIngredientsServing float64 `json:"fruits-vegetables-legumes-estimate-from-ingredients_serving" bson:"fruits-vegetables-legumes-estimate-from-ingredients_serving,truncate"` | |
| ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"` | |
| TransFatValue float64 `json:"trans-fat_value" bson:"trans-fat_value,truncate"` | |
| FruitsVegetablesNutsEstimateFromIngredientsServing float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_serving" bson:"fruits-vegetables-nuts-estimate-from-ingredients-servin |
| EnergyKcal100g float64 `json:"energy-kcal_100g" bson:"energy-kcal_100g,truncate"` | ||
| EnergyKcalValue float64 `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"` | ||
| MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"` | ||
| FatValue float64 `json:"fat_value" bson:"fat_value,truncate"` |
There was a problem hiding this comment.
Fat-related fields changed from int to float64. This is a type-breaking change that could affect API consumers expecting integer values. Ensure all clients can handle floating-point values for fat measurements.
| FatValue float64 `json:"fat_value" bson:"fat_value,truncate"` | |
| FatValue int `json:"fat_value" bson:"fat_value,truncate"` |
| MonounsaturatedFat100g float64 `json:"monounsaturated-fat_100g" bson:"monounsaturated-fat_100g,truncate"` | ||
| EnergyUnit string `json:"energy_unit" bson:"energy_unit"` | ||
| Energy100g float64 `json:"energy_100g" bson:"energy_100g,truncate"` | ||
| PolyunsaturatedFatValue float64 `json:"polyunsaturated-fat_value" bson:"polyunsaturated-fat_value,truncate"` | ||
| Fat100g float64 `json:"fat_100g" bson:"fat_100g,truncate"` | ||
| CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value,truncate"` | ||
| EnergyKcalUnit string `json:"energy-kcal_unit" bson:"energy-kcal_unit"` | ||
| Sodium float64 `json:"sodium" bson:"sodium,truncate"` | ||
| FatUnit string `json:"fat_unit" bson:"fat_unit"` | ||
| FruitsVegetablesNutsEstimateFromIngredients100g float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_100g" bson:"fruits-vegetables-nuts-estimate-from-ingredients_100g,truncate"` | ||
| FatServing float64 `json:"fat_serving" bson:"fat_serving,truncate"` | ||
| Fat float64 `json:"fat" bson:"fat,truncate"` | ||
| MonounsaturatedFatServing float64 `json:"monounsaturated-fat_serving" bson:"monounsaturated-fat_serving,truncate"` |
There was a problem hiding this comment.
Fat-related fields changed from int to float64. This is a type-breaking change that could affect API consumers expecting integer values. Ensure all clients can handle floating-point values for fat measurements.
| MonounsaturatedFat100g float64 `json:"monounsaturated-fat_100g" bson:"monounsaturated-fat_100g,truncate"` | |
| EnergyUnit string `json:"energy_unit" bson:"energy_unit"` | |
| Energy100g float64 `json:"energy_100g" bson:"energy_100g,truncate"` | |
| PolyunsaturatedFatValue float64 `json:"polyunsaturated-fat_value" bson:"polyunsaturated-fat_value,truncate"` | |
| Fat100g float64 `json:"fat_100g" bson:"fat_100g,truncate"` | |
| CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value,truncate"` | |
| EnergyKcalUnit string `json:"energy-kcal_unit" bson:"energy-kcal_unit"` | |
| Sodium float64 `json:"sodium" bson:"sodium,truncate"` | |
| FatUnit string `json:"fat_unit" bson:"fat_unit"` | |
| FruitsVegetablesNutsEstimateFromIngredients100g float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_100g" bson:"fruits-vegetables-nuts-estimate-from-ingredients_100g,truncate"` | |
| FatServing float64 `json:"fat_serving" bson:"fat_serving,truncate"` | |
| Fat float64 `json:"fat" bson:"fat,truncate"` | |
| MonounsaturatedFatServing float64 `json:"monounsaturated-fat_serving" bson:"monounsaturated-fat_serving,truncate"` | |
| MonounsaturatedFat100g int `json:"monounsaturated-fat_100g" bson:"monounsaturated-fat_100g,truncate"` | |
| EnergyUnit string `json:"energy_unit" bson:"energy_unit"` | |
| Energy100g float64 `json:"energy_100g" bson:"energy_100g,truncate"` | |
| PolyunsaturatedFatValue int `json:"polyunsaturated-fat_value" bson:"polyunsaturated-fat_value,truncate"` | |
| Fat100g int `json:"fat_100g" bson:"fat_100g,truncate"` | |
| CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value,truncate"` | |
| EnergyKcalUnit string `json:"energy-kcal_unit" bson:"energy-kcal_unit"` | |
| Sodium float64 `json:"sodium" bson:"sodium,truncate"` | |
| FatUnit string `json:"fat_unit" bson:"fat_unit"` | |
| FruitsVegetablesNutsEstimateFromIngredients100g float64 `json:"fruits-vegetables-nuts-estimate-from-ingredients_100g" bson:"fruits-vegetables-nuts-estimate-from-ingredients_100g,truncate"` | |
| FatServing int `json:"fat_serving" bson:"fat_serving,truncate"` | |
| Fat int `json:"fat" bson:"fat,truncate"` | |
| MonounsaturatedFatServing int `json:"monounsaturated-fat_serving" bson:"monounsaturated-fat_serving,truncate"` |
| FatServing float64 `json:"fat_serving" bson:"fat_serving,truncate"` | ||
| Fat float64 `json:"fat" bson:"fat,truncate"` |
There was a problem hiding this comment.
Fat-related fields changed from int to float64. This is a type-breaking change that could affect API consumers expecting integer values. Ensure all clients can handle floating-point values for fat measurements.
| MonounsaturatedFat float64 `json:"monounsaturated-fat" bson:"monounsaturated-fat,truncate"` | ||
| FatValue float64 `json:"fat_value" bson:"fat_value,truncate"` | ||
| FruitsVegetablesLegumesEstimateFromIngredientsServing float64 `json:"fruits-vegetables-legumes-estimate-from-ingredients_serving" bson:"fruits-vegetables-legumes-estimate-from-ingredients_serving,truncate"` | ||
| ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"` |
There was a problem hiding this comment.
Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.
| ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"` | |
| ProteinsValue int `json:"proteins_value" bson:"proteins_value,truncate"` |
| ProteinsServing float64 `json:"proteins_serving" bson:"proteins_serving,truncate"` | ||
| PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"` | ||
| TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"` | ||
| PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"` | ||
| Proteins100g float64 `json:"proteins_100g" bson:"proteins_100g,truncate"` | ||
| PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"` | ||
| CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"` | ||
| SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"` | ||
| Proteins float64 `json:"proteins" bson:"proteins,truncate"` |
There was a problem hiding this comment.
Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.
| ProteinsServing float64 `json:"proteins_serving" bson:"proteins_serving,truncate"` | |
| PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"` | |
| TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"` | |
| PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"` | |
| Proteins100g float64 `json:"proteins_100g" bson:"proteins_100g,truncate"` | |
| PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"` | |
| CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"` | |
| SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"` | |
| Proteins float64 `json:"proteins" bson:"proteins,truncate"` | |
| ProteinsServing int `json:"proteins_serving" bson:"proteins_serving,truncate"` | |
| PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"` | |
| TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"` | |
| PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"` | |
| Proteins100g int `json:"proteins_100g" bson:"proteins_100g,truncate"` | |
| PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"` | |
| CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"` | |
| SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"` | |
| Proteins int `json:"proteins" bson:"proteins,truncate"` |
| ProteinsServing float64 `json:"proteins_serving" bson:"proteins_serving,truncate"` | ||
| PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"` | ||
| TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"` | ||
| PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"` | ||
| Proteins100g float64 `json:"proteins_100g" bson:"proteins_100g,truncate"` | ||
| PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"` | ||
| CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"` | ||
| SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"` | ||
| Proteins float64 `json:"proteins" bson:"proteins,truncate"` |
There was a problem hiding this comment.
Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.
| ProteinsServing float64 `json:"proteins_serving" bson:"proteins_serving,truncate"` | |
| PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"` | |
| TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"` | |
| PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"` | |
| Proteins100g float64 `json:"proteins_100g" bson:"proteins_100g,truncate"` | |
| PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"` | |
| CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"` | |
| SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"` | |
| Proteins float64 `json:"proteins" bson:"proteins,truncate"` | |
| ProteinsServing int `json:"proteins_serving" bson:"proteins_serving,truncate"` | |
| PolyunsaturatedFat float64 `json:"polyunsaturated-fat" bson:"polyunsaturated-fat,truncate"` | |
| TransFat float64 `json:"trans-fat" bson:"trans-fat,truncate"` | |
| PolyunsaturatedFatUnit string `json:"polyunsaturated-fat_unit" bson:"polyunsaturated-fat_unit"` | |
| Proteins100g int `json:"proteins_100g" bson:"proteins_100g,truncate"` | |
| PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"` | |
| CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"` | |
| SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"` | |
| Proteins int `json:"proteins" bson:"proteins,truncate"` |
| PolyunsaturatedFatServing float64 `json:"polyunsaturated-fat_serving" bson:"polyunsaturated-fat_serving,truncate"` | ||
| CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"` | ||
| SodiumUnit string `json:"sodium_unit" bson:"sodium_unit"` | ||
| Proteins float64 `json:"proteins" bson:"proteins,truncate"` |
There was a problem hiding this comment.
Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.
No description provided.