removed name from model which is not needed and updated method which was using name instead of product id

main
alex 2024-06-10 23:05:31 +02:00
parent 7e53f20a5e
commit 1ac158976e
3 changed files with 3 additions and 5 deletions

BIN
main

Binary file not shown.

View File

@ -3,7 +3,6 @@ package structs
// database model
type PipelineProduct struct {
Id string
Name string
Votes int
}

View File

@ -149,7 +149,6 @@ func fetchProducts(srv *sheets.Service) error {
if !isPipelineProductInDatabase(databasePipelineProducts, productId) {
database.DB.Create(&structs.PipelineProduct{
Id: productId,
Name: name,
Votes: 0,
})
}
@ -160,7 +159,7 @@ func fetchProducts(srv *sheets.Service) error {
futureProducts = append(futureProducts, structs.FutureProduct{
Id: productId,
Name: name,
Votes: getVotes(databasePipelineProducts, name), // votes from database
Votes: getVotes(databasePipelineProducts, productId), // votes from database
Variant: productVariant,
Characteristics: productCharacteristics,
})
@ -211,9 +210,9 @@ func fetchProducts(srv *sheets.Service) error {
return nil
}
func getVotes(pipelineProducts []structs.PipelineProduct, name string) int {
func getVotes(pipelineProducts []structs.PipelineProduct, id string) int {
for _, pipelineProduct := range pipelineProducts {
if pipelineProduct.Name == name {
if pipelineProduct.Id == id {
return pipelineProduct.Votes
}
}