mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix(coderd): use insights for DAUs, simplify metricscache (#12775)
Fixes #12134 Fixes https://github.com/coder/customers/issues/384 Refs #12122
This commit is contained in:
committed by
GitHub
parent
5d82a78d4c
commit
421bf7e785
@ -788,29 +788,9 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
|
||||
// @Success 200 {object} codersdk.DAUsResponse
|
||||
// @Router /templates/{template}/daus [get]
|
||||
func (api *API) templateDAUs(rw http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
template := httpmw.TemplateParam(r)
|
||||
|
||||
vals := r.URL.Query()
|
||||
p := httpapi.NewQueryParamParser()
|
||||
tzOffset := p.Int(vals, 0, "tz_offset")
|
||||
p.ErrorExcessParams(vals)
|
||||
if len(p.Errors) > 0 {
|
||||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
||||
Message: "Query parameters have invalid values.",
|
||||
Validations: p.Errors,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
_, resp, _ := api.metricsCache.TemplateDAUs(template.ID, tzOffset)
|
||||
if resp == nil || resp.Entries == nil {
|
||||
httpapi.Write(ctx, rw, http.StatusOK, &codersdk.DAUsResponse{
|
||||
Entries: []codersdk.DAUEntry{},
|
||||
})
|
||||
return
|
||||
}
|
||||
httpapi.Write(ctx, rw, http.StatusOK, resp)
|
||||
api.returnDAUsInternal(rw, r, []uuid.UUID{template.ID})
|
||||
}
|
||||
|
||||
// @Summary Get template examples by organization
|
||||
|
Reference in New Issue
Block a user