Skip to content
Closed
Show file tree
Hide file tree
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
15 changes: 3 additions & 12 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@ const docTemplate = `{
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "support@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
Expand Down Expand Up @@ -1518,7 +1509,7 @@ const docTemplate = `{
"type": "string"
},
"product_quantity": {
"type": "number"
"type": "string"
},
"product_type": {
"type": "string"
Expand Down Expand Up @@ -1586,7 +1577,7 @@ const docTemplate = `{
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:80",
Host: "",
BasePath: "/api/v1",
Schemes: []string{},
Title: "Database API Wrapper",
Expand Down
14 changes: 2 additions & 12 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@
"info": {
"description": "API for accessing the SnackLog product database.",
"title": "Database API Wrapper",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "support@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"contact": {},
"version": "1.0"
},
"host": "localhost:80",
"basePath": "/api/v1",
"paths": {
"/products/search": {
Expand Down Expand Up @@ -1512,7 +1502,7 @@
"type": "string"
},
"product_quantity": {
"type": "number"
"type": "string"
},
"product_type": {
"type": "string"
Expand Down
12 changes: 2 additions & 10 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ definitions:
product_name_de:
type: string
product_quantity:
type: number
type: string
product_type:
type: string
quantity:
Expand Down Expand Up @@ -929,17 +929,9 @@ definitions:
items: {}
type: array
type: object
host: localhost:80
info:
contact:
email: support@swagger.io
name: API Support
url: http://www.swagger.io/support
contact: {}
description: API for accessing the SnackLog product database.
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: http://swagger.io/terms/
title: Database API Wrapper
version: "1.0"
paths:
Expand Down
2 changes: 1 addition & 1 deletion internal/database/product/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Product struct {
UniqueScansN int `json:"unique_scans_n" bson:"unique_scans_n,truncate"`
FoodGroupsTags []interface{} `json:"food_groups_tags" bson:"food_groups_tags,truncate"`
States string `json:"states" bson:"states"`
ProductQuantity float64 `json:"product_quantity" bson:"product_quantity,truncate"`
ProductQuantity string `json:"product_quantity" bson:"product_quantity,truncate"`
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Changing ProductQuantity from float64 to string will likely break BSON decoding from MongoDB when existing documents store product_quantity as a numeric type (and vice versa if some docs store it as a string). The Go MongoDB driver cannot decode a BSON double/int directly into a Go string, so FindOne().Decode()/cursor.All() can start failing at runtime for mixed-type data. Consider introducing a dedicated type for this field that implements BSON unmarshalling (and JSON unmarshalling if needed) to accept both string and numeric representations and normalize to a string, rather than switching the struct field to plain string.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

bson:"product_quantity,truncate" was previously meaningful for a numeric type; on a string field it’s inconsistent with the rest of this struct (no other string fields use truncate) and can be misleading. Recommend dropping the truncate option if the field remains non-numeric, or keeping the field numeric internally and converting at the API boundary.

Suggested change
ProductQuantity string `json:"product_quantity" bson:"product_quantity,truncate"`
ProductQuantity string `json:"product_quantity" bson:"product_quantity"`

Copilot uses AI. Check for mistakes.
Brands string `json:"brands" bson:"brands"`
Quantity string `json:"quantity" bson:"quantity"`
EnvironmentalScoreData struct {
Expand Down