display commit at recipe

This commit is contained in:
pakintada@gmail.com 2023-12-06 10:05:16 +07:00
parent 820557a268
commit f2ec0ed5fa
6 changed files with 640 additions and 555 deletions

View file

@ -370,31 +370,38 @@ func (rr *RecipeRouter) Route(r chi.Router) {
return
}
recipe_root_path := "./cofffeemachineConfig/"
// recipe_root_path := "./cofffeemachineConfig/"
// structure
full_file_name_targets := []string{}
// full_file_name_targets := []string{}
files, err := os.ReadDir(recipe_root_path + countryID)
// files, err := os.ReadDir(recipe_root_path + countryID)
// if err != nil {
// Log.Error("Error when read directory", zap.Error(err))
// return
// }
// for _, file := range files {
// Log.Debug("File: ", zap.Any("file", file.Name()))
// if strings.Contains(file.Name(), file_version) && strings.Contains(file.Name(), ".tmp") {
// full_file_name_targets = append(full_file_name_targets, file.Name())
// }
// }
commits, err := data.GetCommitLogOfFilename(countryID, file_version)
if err != nil {
Log.Error("Error when read directory", zap.Error(err))
Log.Error("Error when get commit log", zap.Error(err))
return
}
for _, file := range files {
Log.Debug("File: ", zap.Any("file", file.Name()))
if strings.Contains(file.Name(), file_version) && strings.Contains(file.Name(), ".tmp") {
full_file_name_targets = append(full_file_name_targets, file.Name())
}
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(map[string]interface{}{"files": full_file_name_targets})
json.NewEncoder(w).Encode(map[string]interface{}{"files": commits})
Log.Debug("Saved Files: ", zap.Any("files", full_file_name_targets))
Log.Debug("Saved Files: ", zap.Any("files", commits))
})
})
}