Skip to content

Commit

Permalink
Cleanup debug logging, keep orderBy param for repo.Find
Browse files Browse the repository at this point in the history
  • Loading branch information
spacehamster87 committed Oct 31, 2024
1 parent 2c8b73e commit 939dd23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion internal/api/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions internal/repository/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
15 changes: 4 additions & 11 deletions internal/routerConfig/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -78,8 +76,6 @@ func setupHomeRoute(i InfoType, r *http.Request) InfoType {
}
}

log.Infof("... BYE HOME ROUTE")

return i
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit 939dd23

Please sign in to comment.