removed name from model which is not needed and updated method which was using name instead of product id
parent
7e53f20a5e
commit
1ac158976e
|
@ -3,7 +3,6 @@ package structs
|
|||
// database model
|
||||
type PipelineProduct struct {
|
||||
Id string
|
||||
Name string
|
||||
Votes int
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue