MCPcopy Create free account
hub / github.com/Debian/dcs / QueryzHandler

Function QueryzHandler

cmd/dcs-web/querymanager.go:412–459  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

410}
411
412type queryStats struct {
413 Searchterm string
414 QueryId string
415 NumEvents int
416 NumResults int
417 NumResultPages int
418 NumPackages int
419 Done bool
420 Started time.Time
421 Ended time.Time
422 StartedFromNow time.Duration
423 Duration time.Duration
424 FilesTotal []int
425 FilesProcessed []int
426}
427
428func QueryzHandler(w http.ResponseWriter, r *http.Request) {
429 r.ParseForm()
430 if cancel := r.PostFormValue("cancel"); cancel != "" {
431 addEventMarshal(cancel, &Error{
432 Type: "error",
433 ErrorType: "cancelled",
434 })
435 finishQuery(cancel)
436 http.Redirect(w, r, "/queryz", http.StatusFound)
437 return
438 }
439
440 stateMu.RLock()
441 stats := make([]queryStats, len(state))
442 idx := 0
443 for queryid, s := range state {
444 stats[idx] = queryStats{
445 Searchterm: s.query,
446 QueryId: queryid,
447 NumEvents: len(s.events),
448 Done: s.done,
449 Started: s.started,
450 Ended: s.ended,
451 StartedFromNow: time.Since(s.started),
452 Duration: s.ended.Sub(s.started),
453 NumResults: s.numResults(),
454 NumResultPages: s.resultPages,
455 FilesTotal: s.filesTotal,
456 FilesProcessed: s.filesProcessed,
457 }
458 if stats[idx].NumResults == 0 && stats[idx].Done {
459 stats[idx].NumResults = s.numResults()
460 }
461 idx++
462 }

Callers

nothing calls this directly

Calls 4

addEventMarshalFunction · 0.85
finishQueryFunction · 0.85
numResultsMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected