fix(sorting): 🐛 fix unchanged sorting result
This commit is contained in:
parent
ef9cf48fc1
commit
b53183d884
5 changed files with 358 additions and 103 deletions
|
|
@ -842,22 +842,20 @@ func (rr *RecipeRouter) sortRecipe(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
sortKey := sortConfig["sortKey"].(string)
|
||||
ascending := sortConfig["ascending"].(bool)
|
||||
|
||||
// store cache
|
||||
rr.cache_db.SetKeyTimeout(country+"_"+filename+"_latestSortKey", sortKey, 3600)
|
||||
rr.cache_db.SetKeyTimeout(country+"_"+filename+"_"+sortKey, ascending, 3600)
|
||||
|
||||
// sort recipe
|
||||
err, emptiedComparators := rr.data.SortRecipe(country, filename, sortKey)
|
||||
|
||||
if err != nil {
|
||||
|
||||
rr.taoLogger.Log.Error("RecipeRouter.sortRecipe", zap.Error(err), zap.Any("emptiedComparators", emptiedComparators))
|
||||
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
rr.data.SortRecipe(country, filename, sortKey, ascending)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"status": "OK",
|
||||
"key": sortKey,
|
||||
"result": rr.data.GetRecipe(country, filename).Recipe01,
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue