api for health score toggle test reverse
This commit is contained in:
@@ -214,7 +214,18 @@ type Products struct {
|
||||
// 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"`
|
||||
//
|
||||
// NO `default` IN THE GORM TAG, and that is not an oversight. GORM skips a
|
||||
// zero-value field whose tag names a default, so `false` was never written:
|
||||
// the INSERT omitted the column, the database default of true applied, and a
|
||||
// product imported with the score switched off came back switched on. It
|
||||
// shipped that way and was found by importing one and reading it back.
|
||||
//
|
||||
// The DEFAULT lives on the column instead, set by the migration in main.go.
|
||||
// That still covers what it is for — rows that predate the column, and any
|
||||
// INSERT that genuinely omits it — without teaching GORM to drop a
|
||||
// deliberate false on the way past.
|
||||
Showhealthscore bool `json:"showhealthscore" gorm:"column:showhealthscore"`
|
||||
|
||||
Productdesc string `json:"productdesc,omitempty"`
|
||||
Productsku string `json:"productsku,omitempty"`
|
||||
@@ -331,6 +342,19 @@ type Locationproducts struct {
|
||||
Diffpercent float64 `json:"diffpercent,omitempty"`
|
||||
Othercost float64 `json:"othercost,omitempty"`
|
||||
Approve int `json:"approve" gorm:"default:0"`
|
||||
// Whether this product's health score is shown to shoppers.
|
||||
//
|
||||
// It has to be HERE and not only on Products, because this is the struct the
|
||||
// admin catalogue reads. Without it the console received no value at all,
|
||||
// the drawer's switch rendered "on" for every product including the ones
|
||||
// that were off, and a product already hidden showed no panel and so no way
|
||||
// to turn it back on. The column was being written correctly the whole time
|
||||
// and simply never read back — which also made every "it did not save"
|
||||
// reading taken from this endpoint meaningless.
|
||||
//
|
||||
// No `omitempty`: a false has to survive the trip, and omitempty would drop
|
||||
// exactly the value this field exists to carry.
|
||||
Showhealthscore bool `json:"showhealthscore"`
|
||||
// Productstatus string `json:"productstatus" gorm:"default:available"`
|
||||
Status string `json:"status" gorm:"default:outofstock"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user