api for health score toggle

This commit is contained in:
2026-10-05 12:07:49 +05:30
parent 97f277f424
commit fc2caffcd1
7 changed files with 358 additions and 1 deletions

View File

@@ -197,6 +197,25 @@ type Products struct {
// models.IsEdible.
Healthscore *HealthScore `json:"healthscore,omitempty" gorm:"-"`
// Whether this shop shows a health score for this product.
//
// A real column, unlike the two above. The shopkeeper's call: the score
// comes from a third party matching a reference product by name, often
// under 60% confidence, and a merchant who knows the packet may reasonably
// decide the rating does not describe what they sell.
//
// Defaults true, so every product imported before this column existed keeps
// showing what it shows today.
//
// Gates `Healthscore` and NOTHING else. `Nutrition` is always sent — the
// figures are what the packet says, the score is a judgement of them, and a
// merchant turning off the judgement is not disputing the grams.
//
// The PLATFORM console ignores this: Nearle staff see every score on every
// product, because the decision being made there is whether the data is good
// enough to publish at all.
Showhealthscore bool `json:"showhealthscore" gorm:"column:showhealthscore;default:true"`
Productdesc string `json:"productdesc,omitempty"`
Productsku string `json:"productsku,omitempty"`
Brandid int `json:"brandid,omitempty"`
@@ -492,6 +511,14 @@ type ImportCatalogueProductRequest struct {
Retailprice float64 `json:"retailprice"`
Productcost float64 `json:"productcost"`
Taxpercent float64 `json:"taxpercent"`
// Whether this shop will show the product's health score.
//
// A POINTER so "not sent" and "sent as false" stay different answers. Every
// caller that predates this field omits it, and a bare bool would read those
// as a deliberate no and strip the score from every import made by an older
// console. Nil means "they did not say", which is treated as yes.
Showhealthscore *bool `json:"showhealthscore"`
}
type Productlocations struct {