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