update recipe list and disable git pulling
This commit is contained in:
parent
15e74d47e3
commit
fea5f8452a
7 changed files with 171 additions and 133 deletions
|
|
@ -3,6 +3,7 @@ package data
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"recipe-manager/helpers"
|
||||
"recipe-manager/models"
|
||||
"recipe-manager/services/logger"
|
||||
|
|
@ -47,7 +48,11 @@ func NewData() *Data {
|
|||
|
||||
defaultFile := "coffeethai02_580.json"
|
||||
defaultCountry := "thai"
|
||||
defaultRecipe := helpers.ReadRecipeFile(defaultCountry, defaultFile)
|
||||
defaultRecipe, err := helpers.ReadRecipeFile(defaultCountry, defaultFile)
|
||||
|
||||
if err != nil {
|
||||
log.Panic("Error when read default recipe file:", err)
|
||||
}
|
||||
|
||||
return &Data{
|
||||
CurrentFile: defaultFile,
|
||||
|
|
@ -83,7 +88,14 @@ func (d *Data) GetRecipe(countryID, filename string) models.Recipe {
|
|||
// change current version and read new recipe
|
||||
d.CurrentFile = filename
|
||||
d.CurrentCountryID = countryID
|
||||
d.currentRecipe = helpers.ReadRecipeFile(countryID, filename)
|
||||
recipe, err := helpers.ReadRecipeFile(countryID, filename)
|
||||
|
||||
if err != nil {
|
||||
logger.GetInstance().Error("Error when read recipe file", zap.Error(err))
|
||||
return *d.currentRecipe
|
||||
}
|
||||
|
||||
d.currentRecipe = recipe
|
||||
|
||||
// save to map
|
||||
if len(d.recipeMap) > 5 { // limit keep in memory 5 version
|
||||
|
|
@ -154,7 +166,15 @@ func (d *Data) GetMaterialSetting(countryID, filename string) []models.MaterialS
|
|||
|
||||
d.CurrentFile = filename
|
||||
d.CurrentCountryID = countryID
|
||||
d.currentRecipe = helpers.ReadRecipeFile(countryID, filename)
|
||||
recipe, err := helpers.ReadRecipeFile(countryID, filename)
|
||||
|
||||
if err != nil {
|
||||
logger.GetInstance().Error("Error when read recipe file", zap.Error(err))
|
||||
copy(result, d.currentRecipe.MaterialSetting)
|
||||
return result
|
||||
}
|
||||
|
||||
d.currentRecipe = recipe
|
||||
|
||||
// save to map
|
||||
if len(d.recipeMap) > 5 { // limit keep in memory 5 version
|
||||
|
|
@ -190,7 +210,14 @@ func (d *Data) GetMaterialCode(ids []uint64, countryID, filename string) []model
|
|||
} else {
|
||||
d.CurrentFile = filename
|
||||
d.CurrentCountryID = countryID
|
||||
d.currentRecipe = helpers.ReadRecipeFile(countryID, filename)
|
||||
recipe, err := helpers.ReadRecipeFile(countryID, filename)
|
||||
|
||||
if err != nil {
|
||||
logger.GetInstance().Error("Error when read recipe file", zap.Error(err))
|
||||
return d.currentRecipe.MaterialCode
|
||||
}
|
||||
|
||||
d.currentRecipe = recipe
|
||||
|
||||
// save to map
|
||||
if len(d.recipeMap) > 5 { // limit keep in memory 5 version
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue