add changes diffing modal & silence some logs
This commit is contained in:
parent
148488e2c4
commit
da353cec84
22 changed files with 1770 additions and 120 deletions
|
|
@ -198,6 +198,8 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
return
|
||||
}
|
||||
})
|
||||
|
||||
r.Post("/sort/{country}/{filename}", rr.sortRecipe)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -594,7 +596,7 @@ func (rr *RecipeRouter) getSavedRecipes(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
|
||||
commits, err := data.GetCommitLogOfFilename(countryID, file_version)
|
||||
// fmt.Println("commits", commits)
|
||||
// //fmt.Println("commits", commits)
|
||||
rr.taoLogger.Log.Debug("RecipeRouter.getSavedRecipes", zap.Any("commits", commits))
|
||||
|
||||
if err != nil || len(commits) == 0 {
|
||||
|
|
@ -836,3 +838,37 @@ func lockThenTimeout(mutex *sync.Mutex, timeout time.Duration) bool {
|
|||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ Sorting ------------------
|
||||
func (rr *RecipeRouter) sortRecipe(w http.ResponseWriter, r *http.Request) {
|
||||
country := chi.URLParam(r, "country")
|
||||
filename := chi.URLParam(r, "filename")
|
||||
|
||||
// get sort type from body
|
||||
var sortConfig map[string]interface{}
|
||||
err := json.NewDecoder(r.Body).Decode(&sortConfig)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
sortKey := sortConfig["sortKey"].(string)
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"status": "OK",
|
||||
"key": sortKey,
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue