feat(add country settings): ✨
This commit is contained in:
parent
b53183d884
commit
8744ddcb8c
2 changed files with 62 additions and 1 deletions
|
|
@ -186,9 +186,42 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
func LoadCountrySettings() []helpers.CountryName {
|
||||
res := make([]helpers.CountryName, 0)
|
||||
|
||||
// read file country.settings.json
|
||||
content, err := os.Open("country.settings.json")
|
||||
if err != nil {
|
||||
fmt.Errorf("country.settings.json not found")
|
||||
}
|
||||
|
||||
// read content to json
|
||||
var countrySettings []map[string]interface{}
|
||||
err = json.NewDecoder(content).Decode(&countrySettings)
|
||||
|
||||
if err != nil {
|
||||
fmt.Errorf("error in country.settings")
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, v := range countrySettings {
|
||||
if ignore, ok := v["ignore"].(bool); ok {
|
||||
if ignore {
|
||||
continue
|
||||
}
|
||||
}
|
||||
res = append(res, helpers.CountryName{
|
||||
CountryID: v["short"].(string),
|
||||
CountryName: v["name"].(string),
|
||||
})
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func NewData(taoLogger *logger.TaoLogger, redisClient *RedisCli) *Data {
|
||||
|
||||
allRecipeFiles := helpers.ScanRecipeFiles(countries)
|
||||
allRecipeFiles := helpers.ScanRecipeFiles(LoadCountrySettings())
|
||||
|
||||
defaultFile := "coffeethai02_600.json"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue