Cleanup debug logging, keep orderBy param for repo.Find

This commit is contained in:
Christoph Kluge 2024-10-31 15:47:45 +01:00
parent 2c8b73e2e2
commit 939dd2320a
3 changed files with 8 additions and 15 deletions

View File

@ -929,7 +929,7 @@ func (api *RestApi) stopJobByRequest(rw http.ResponseWriter, r *http.Request) {
return
}
log.Printf("loading db job for stopJobByRequest... : stopJobApiRequest=%v", req)
// log.Printf("loading db job for stopJobByRequest... : stopJobApiRequest=%v", req)
job, err = api.JobRepository.Find(req.JobId, req.Cluster, req.StartTime)
if err != nil {

View File

@ -235,10 +235,10 @@ func (r *JobRepository) Find(
q = q.Where("job.start_time = ?", *startTime)
}
q = q.OrderBy("job.id DESC") // always use newest matching job by db id
q = q.OrderBy("job.id DESC") // always use newest matching job by db id if more than one match
s, args, _ := q.ToSql()
log.Printf("trying to find db job with query: %s | %v", s, args)
// s, args, _ := q.ToSql()
// log.Printf("trying to find db job with query: %s | %v", s, args)
log.Debugf("Timer Find %s", time.Since(start))
return scanJob(q.RunWith(r.stmtCache).QueryRow())

View File

@ -51,21 +51,19 @@ func setupHomeRoute(i InfoType, r *http.Request) InfoType {
jobRepo := repository.GetJobRepository()
groupBy := model.AggregateCluster
log.Infof(">>> HELLO HOME ROUTE")
startJobCount := time.Now()
// startJobCount := time.Now()
stats, err := jobRepo.JobCountGrouped(r.Context(), nil, &groupBy)
if err != nil {
log.Warnf("failed to count jobs: %s", err.Error())
}
log.Infof("Timer HOME ROUTE startJobCount: %s", time.Since(startJobCount))
// log.Infof("Timer HOME ROUTE startJobCount: %s", time.Since(startJobCount))
startRunningJobCount := time.Now()
// startRunningJobCount := time.Now()
stats, err = jobRepo.AddJobCountGrouped(r.Context(), nil, &groupBy, stats, "running")
if err != nil {
log.Warnf("failed to count running jobs: %s", err.Error())
}
log.Infof("Timer HOME ROUTE startRunningJobCount: %s", time.Since(startRunningJobCount))
// log.Infof("Timer HOME ROUTE startRunningJobCount: %s", time.Since(startRunningJobCount))
i["clusters"] = stats
@ -78,8 +76,6 @@ func setupHomeRoute(i InfoType, r *http.Request) InfoType {
}
}
log.Infof("... BYE HOME ROUTE")
return i
}
@ -262,8 +258,6 @@ func SetupRoutes(router *mux.Router, buildInfo web.Build) {
for _, route := range routes {
route := route
router.HandleFunc(route.Route, func(rw http.ResponseWriter, r *http.Request) {
log.Info(">>> HELLO ROUTE HANDLER ...")
conf, err := userCfgRepo.GetUIConfig(repository.GetUserFromContext(r.Context()))
if err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError)
@ -294,7 +288,6 @@ func SetupRoutes(router *mux.Router, buildInfo web.Build) {
if route.Filter {
page.FilterPresets = buildFilterPresets(r.URL.Query())
}
log.Infof("... ROUTE HANDLED: %s for %v", page.Title, page.User)
web.RenderTemplate(rw, route.Template, &page)
})