api for health score toggle
This commit is contained in:
20
main.go
20
main.go
@@ -176,6 +176,26 @@ func main() {
|
||||
log.Println("⚠️ could not add products.cataloguefacts, catalogue detail will not survive a re-scrape:", err)
|
||||
}
|
||||
|
||||
// Whether this shop shows a health score for this product.
|
||||
//
|
||||
// The shopkeeper's call, not ours. The score comes from a third party that
|
||||
// matches a reference product by name — often at under 60% confidence — so a
|
||||
// merchant who knows the packet in front of them may reasonably decide the
|
||||
// rating does not describe what they are selling, and should be able to take
|
||||
// it off their own shelf without taking it off everybody's.
|
||||
//
|
||||
// DEFAULT TRUE, so every product already imported keeps showing exactly what
|
||||
// it shows today. A new column defaulting to false would silently strip the
|
||||
// health score from every shelf on the platform, which is a change nobody
|
||||
// asked for dressed up as a migration.
|
||||
//
|
||||
// Only the score. `nutrition` is unaffected and always sent: the figures are
|
||||
// what the packet says, while the score is somebody's judgement of them.
|
||||
if err := db.DB.Exec(
|
||||
`ALTER TABLE products ADD COLUMN IF NOT EXISTS showhealthscore boolean NOT NULL DEFAULT true`).Error; err != nil {
|
||||
log.Println("⚠️ could not add products.showhealthscore, every product will keep showing its health score:", err)
|
||||
}
|
||||
|
||||
// When a product became visible to a store, and the only thing that decides
|
||||
// whether it is.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user