change ignore fresh updated, do update after merge instead.

This commit is contained in:
pakintada@gmail.com 2024-02-23 16:48:23 +07:00
parent fed315367a
commit ed7810cded
3 changed files with 54 additions and 27 deletions

View file

@ -448,6 +448,8 @@ func (rr *RecipeRouter) updateRecipe(w http.ResponseWriter, r *http.Request) {
// Apply changes
tempRecipe := models.Recipe01{}
tempRecipe = tempRecipe.FromMap(changeMap)
// Disable temp! Was updated the master by patch. Too fast
rr.data.SetValuesToRecipe(targetRecipe.Recipe01, tempRecipe)
rr.taoLogger.Log.Debug("ApplyChange", zap.Any("status", "passed"))
@ -502,36 +504,35 @@ func (rr *RecipeRouter) updateRecipe(w http.ResponseWriter, r *http.Request) {
return
}
} else {
}
// this following codes do need users to pass update to each other
// otherwise, the changes will diverge
// this following codes do need users to pass update to each other
// otherwise, the changes will diverge
file, _ := os.Create(temp_file_name)
if err != nil {
rr.taoLogger.Log.Error("RecipeRouter.UpdateRecipe", zap.Error(errors.WithMessage(err, "Error when tried to create file")))
http.Error(w, "Internal Error", http.StatusInternalServerError)
return
}
file, _ := os.Create(temp_file_name)
if err != nil {
rr.taoLogger.Log.Error("RecipeRouter.UpdateRecipe", zap.Error(errors.WithMessage(err, "Error when tried to create file")))
http.Error(w, "Internal Error", http.StatusInternalServerError)
return
}
// write to local if cannot connect
encoder := json.NewEncoder(file)
encoder.SetIndent("", " ")
// full
err = encoder.Encode(targetRecipe)
// write to local if cannot connect
encoder := json.NewEncoder(file)
encoder.SetIndent("", " ")
// full
err = encoder.Encode(tempRecipe)
// -------------------------------------------------------------
// -------------------------------------------------------------
// partial
// err = encoder.Encode(changes)
// partial
// err = encoder.Encode(changes)
// put changes to redis
// put changes to redis
if err != nil {
rr.taoLogger.Log.Error("RecipeRouter.UpdateRecipe", zap.Error(errors.WithMessage(err, "Error when write file")))
http.Error(w, "Internal Error", http.StatusInternalServerError)
return
}
if err != nil {
rr.taoLogger.Log.Error("RecipeRouter.UpdateRecipe", zap.Error(errors.WithMessage(err, "Error when write file")))
http.Error(w, "Internal Error", http.StatusInternalServerError)
return
}
// add to commit
@ -624,7 +625,7 @@ func (rr *RecipeRouter) getSavedAsPatches(w http.ResponseWriter, r *http.Request
return
}
rr.taoLogger.Log.Debug("RecipeRouter.getSavedAsPatches", zap.Any("targetPatchOf", countryID+"."+filename+":patchList"), zap.Any("patchList", patchList))
// rr.taoLogger.Log.Debug("RecipeRouter.getSavedAsPatches", zap.Any("targetPatchOf", countryID+"."+filename+":patchList"), zap.Any("patchList", patchList))
// find patch content from patch list
keys, err := rr.cache_db.KeyList()
@ -662,7 +663,11 @@ func (rr *RecipeRouter) getSavedAsPatches(w http.ResponseWriter, r *http.Request
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(patchMap)
rr.taoLogger.Log.Debug("RecipeRouter.getSavedAsPatches", zap.Any("patchMap", patchMap))
// The above code is using the Zap logging library in Go to log a debug message with two fields. The
// first field is "targetPatchOf" with the value of countryID + "." + filename + ":patchList", and the
// second field is "patchList" with the value of the variable patchList. This log message is related
// to the "RecipeRouter.getSavedAsPatches" method.
// rr.taoLogger.Log.Debug("RecipeRouter.getSavedAsPatches", zap.Any("patchMap", patchMap))
}
func (rr *RecipeRouter) getToppings(w http.ResponseWriter, r *http.Request) {