Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 65 additions & 31 deletions internal/database/product/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Energy100G int `json:"energy_100g" bson:"energy_100g,truncate"`
Fat int `json:"fat" bson:"fat,truncate"`
EnergyKcal int `json:"energy-kcal" bson:"energy-kcal,truncate"`
SugarsValue float64 `json:"sugars_value" bson:"sugars_value,truncate"`
SugarsUnit string `json:"sugars_unit" bson:"sugars_unit"`
Carbohydrates float64 `json:"carbohydrates" bson:"carbohydrates,truncate"`
Carbohydrates100G float64 `json:"carbohydrates_100g" bson:"carbohydrates_100g,truncate"`
Energy int `json:"energy" bson:"energy,truncate"`
SugarsServing float64 `json:"sugars_serving" bson:"sugars_serving,truncate"`
Fat100G int `json:"fat_100g" bson:"fat_100g,truncate"`
ProteinsValue int `json:"proteins_value" bson:"proteins_value,truncate"`
EnergyKcalUnit string `json:"energy-kcal_unit" bson:"energy-kcal_unit"`
CarbohydratesValue float64 `json:"carbohydrates_value" bson:"carbohydrates_value,truncate"`
Sugars100G float64 `json:"sugars_100g" bson:"sugars_100g,truncate"`
FatUnit string `json:"fat_unit" bson:"fat_unit"`
CarbohydratesServing float64 `json:"carbohydrates_serving" bson:"carbohydrates_serving,truncate"`
Proteins int `json:"proteins" bson:"proteins,truncate"`
EnergyValue int `json:"energy_value" bson:"energy_value,truncate"`
EnergyUnit string `json:"energy_unit" bson:"energy_unit"`
ProteinsUnit string `json:"proteins_unit" bson:"proteins_unit"`
EnergyKcalValue int `json:"energy-kcal_value" bson:"energy-kcal_value,truncate"`
EnergyKcal100G int `json:"energy-kcal_100g" bson:"energy-kcal_100g,truncate"`
EnergyKcalServing float64 `json:"energy-kcal_serving" bson:"energy-kcal_serving,truncate"`
FatServing int `json:"fat_serving" bson:"fat_serving,truncate"`
CarbohydratesUnit string `json:"carbohydrates_unit" bson:"carbohydrates_unit"`
FatValue int `json:"fat_value" bson:"fat_value,truncate"`
Proteins100G int `json:"proteins_100g" bson:"proteins_100g,truncate"`
ProteinsServing int `json:"proteins_serving" bson:"proteins_serving,truncate"`
EnergyKcalValueComputed int `json:"energy-kcal_value_computed" bson:"energy-kcal_value_computed,truncate"`
EnergyServing int `json:"energy_serving" bson:"energy_serving,truncate"`
Sugars float64 `json:"sugars" bson:"sugars,truncate"`
SaturatedFat float64 `json:"saturated-fat" bson:"saturated-fat,truncate"`
SodiumValue float64 `json:"sodium_value" bson:"sodium_value,truncate"`
MonounsaturatedFatUnit string `json:"monounsaturated-fat_unit" bson:"monounsaturated-fat_unit"`
SaltValue float64 `json:"salt_value" bson:"salt_value,truncate"`
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"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
FatValue float64 `json:"fat_value" bson:"fat_value,truncate"`
FatValue int `json:"fat_value" bson:"fat_value,truncate"`

Copilot uses AI. Check for mistakes.
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"`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.

Suggested change
ProteinsValue float64 `json:"proteins_value" bson:"proteins_value,truncate"`
ProteinsValue int `json:"proteins_value" bson:"proteins_value,truncate"`

Copilot uses AI. Check for mistakes.
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"`
Comment on lines +304 to +316
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
NovaGroup float64 `json:"nova-group" bson:"nova-group,truncate"`
NutritionScoreFr float64 `json:"nutrition-score-fr" bson:"nutrition-score-fr,truncate"`
EnergyKcalValueComputed float64 `json:"energy-kcal_value_computed" bson:"energy-kcal_value_computed,truncate"`
NutritionScoreFr100g float64 `json:"nutrition-score-fr_100g" bson:"nutrition-score-fr_100g,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"`
Comment on lines +331 to +332
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
MonounsaturatedFatServing float64 `json:"monounsaturated-fat_serving" bson:"monounsaturated-fat_serving,truncate"`
Comment on lines +321 to +333
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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"`

Copilot uses AI. Check for mistakes.
Carbohydrates100g float64 `json:"carbohydrates_100g" bson:"carbohydrates_100g,truncate"`
SaturatedFatUnit string `json:"saturated-fat_unit" bson:"saturated-fat_unit"`
EnergyKcalServing float64 `json:"energy-kcal_serving" bson:"energy-kcal_serving,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"`
Comment on lines +337 to +345
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.

Suggested change
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"`

Copilot uses AI. Check for mistakes.
Comment on lines +337 to +345
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.

Suggested change
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"`

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protein-related fields changed from int to float64. This type change may break API consumers expecting integer values. Verify compatibility with all downstream systems.

Copilot uses AI. Check for mistakes.
SaltServing float64 `json:"salt_serving" bson:"salt_serving,truncate"`
Sodium100g float64 `json:"sodium_100g" bson:"sodium_100g,truncate"`
SaltUnit string `json:"salt_unit" bson:"salt_unit"`
Energy float64 `json:"energy" bson:"energy,truncate"`
EnergyValue float64 `json:"energy_value" bson:"energy_value,truncate"`
SaturatedFat100g float64 `json:"saturated-fat_100g" bson:"saturated-fat_100g,truncate"`
CarbohydratesUnit string `json:"carbohydrates_unit" bson:"carbohydrates_unit"`
TransFatUnit string `json:"trans-fat_unit" bson:"trans-fat_unit"`
NovaGroup100g float64 `json:"nova-group_100g" bson:"nova-group_100g,truncate"`
TransFat100g float64 `json:"trans-fat_100g" bson:"trans-fat_100g,truncate"`
SaturatedFatServing float64 `json:"saturated-fat_serving" bson:"saturated-fat_serving,truncate"`
MonounsaturatedFatValue float64 `json:"monounsaturated-fat_value" bson:"monounsaturated-fat_value,truncate"`
SodiumServing float64 `json:"sodium_serving" bson:"sodium_serving,truncate"`
FruitsVegetablesLegumesEstimateFromIngredients100g float64 `json:"fruits-vegetables-legumes-estimate-from-ingredients_100g" bson:"fruits-vegetables-legumes-estimate-from-ingredients_100g,truncate"`
NovaGroupServing float64 `json:"nova-group_serving" bson:"nova-group_serving,truncate"`
PolyunsaturatedFat100g float64 `json:"polyunsaturated-fat_100g" bson:"polyunsaturated-fat_100g,truncate"`
TransFatServing float64 `json:"trans-fat_serving" bson:"trans-fat_serving,truncate"`
EnergyKcal float64 `json:"energy-kcal" bson:"energy-kcal,truncate"`
} `json:"nutriments" bson:"nutriments"`
ServingQuantityUnit string `json:"serving_quantity_unit" bson:"serving_quantity_unit"`
CountriesLc string `json:"countries_lc" bson:"countries_lc"`
Expand Down
Loading