fix switch department not change country

This commit is contained in:
pakintada@gmail.com 2024-02-08 16:40:06 +07:00
parent d9a7961806
commit adefe31090
6 changed files with 152 additions and 92 deletions

View file

@ -229,7 +229,7 @@ func (d *Data) GetRecipe(countryID, filename string) *models.Recipe {
if recipe, ok := d.recipeMap[filename]; ok && d.redisClient.HealthCheck() != nil {
d.taoLogger.Log.Debug("GetRecipe", zap.Any("ValidOnStored", "return from stored "+filename))
d.CurrentFile[countryID] = filename
// d.CurrentFile[countryID] = filename
// d.CurrentCountryID[countryID] = countryID
// make sure recipe vesion is equal
@ -265,7 +265,7 @@ func (d *Data) GetRecipe(countryID, filename string) *models.Recipe {
if cached_recipe != nil {
d.taoLogger.Log.Debug("GetRecipe", zap.Any("Check on cached recipe invalid", cached_recipe == nil), zap.Any("test config number", cached_recipe.MachineSetting.ConfigNumber))
// set to current
d.CurrentRecipe[countryID] = cached_recipe
// d.CurrentRecipe[countryID] = cached_recipe
return cached_recipe
}
@ -287,14 +287,17 @@ func (d *Data) GetRecipe(countryID, filename string) *models.Recipe {
//. service is connected. Use from cache
// check healthcheck redis
var return_recipe *models.Recipe = &models.Recipe{}
err = d.redisClient.HealthCheck()
d.taoLogger.Log.Info("GetRecipe: HealthCheck", zap.Any("result", err))
if d.redisClient.HealthCheck() == nil && cached_recipe != nil {
d.taoLogger.Log.Debug("GetRecipeCached", zap.Any("cached_recipe", "yes"))
d.CurrentRecipe[countryID] = cached_recipe
// d.CurrentRecipe[countryID] = cached_recipe
return_recipe = cached_recipe
} else {
d.taoLogger.Log.Debug("GetRecipeCached", zap.Any("cached_recipe", "no"))
d.CurrentRecipe[countryID] = recipe
// d.CurrentRecipe[countryID] = recipe
return_recipe = recipe
}
// save to map
@ -316,7 +319,7 @@ func (d *Data) GetRecipe(countryID, filename string) *models.Recipe {
TimeStamps: time.Now().Unix(),
}
return d.CurrentRecipe[countryID]
return return_recipe
}
// func (d *Data) GetRecipe01() []models.Recipe01 {