Skip to content
Merged
Next Next commit
codersdk week
  • Loading branch information
mtojek committed Sep 14, 2023
commit f9e2cbebf3120f046d84f2ba6dbfc16ace87e988
4 changes: 2 additions & 2 deletions coderd/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,15 +532,15 @@ func parseInsightsStartAndEndTime(ctx context.Context, rw http.ResponseWriter, s

func verifyInsightsInterval(ctx context.Context, rw http.ResponseWriter, intervalString string) (codersdk.InsightsReportInterval, bool) {
switch v := codersdk.InsightsReportInterval(intervalString); v {
case codersdk.InsightsReportIntervalDay, "":
case codersdk.InsightsReportIntervalDay, codersdk.InsightsReportIntervalWeek, "":
return v, true
default:
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "Query parameter has invalid value.",
Validations: []codersdk.ValidationError{
{
Field: "interval",
Detail: fmt.Sprintf("must be one of %v", []codersdk.InsightsReportInterval{codersdk.InsightsReportIntervalDay}),
Detail: fmt.Sprintf("must be one of %v", []codersdk.InsightsReportInterval{codersdk.InsightsReportIntervalDay, codersdk.InsightsReportIntervalWeek}),
},
},
})
Expand Down
7 changes: 4 additions & 3 deletions codersdk/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type InsightsReportInterval string

// InsightsReportInterval enums.
const (
InsightsReportIntervalDay InsightsReportInterval = "day"
InsightsReportIntervalDay InsightsReportInterval = "day"
InsightsReportIntervalWeek InsightsReportInterval = "week"
)

// UserLatencyInsightsResponse is the response from the user latency insights
Expand Down Expand Up @@ -109,7 +110,7 @@ type TemplateInsightsIntervalReport struct {
StartTime time.Time `json:"start_time" format:"date-time"`
EndTime time.Time `json:"end_time" format:"date-time"`
TemplateIDs []uuid.UUID `json:"template_ids" format:"uuid"`
Interval InsightsReportInterval `json:"interval"`
Interval InsightsReportInterval `json:"interval" example:"week"`
ActiveUsers int64 `json:"active_users" example:"14"`
}

Expand Down Expand Up @@ -155,7 +156,7 @@ type TemplateInsightsRequest struct {
StartTime time.Time `json:"start_time" format:"date-time"`
EndTime time.Time `json:"end_time" format:"date-time"`
TemplateIDs []uuid.UUID `json:"template_ids" format:"uuid"`
Interval InsightsReportInterval `json:"interval"`
Interval InsightsReportInterval `json:"interval" example:"day"`
}

func (c *Client) TemplateInsights(ctx context.Context, req TemplateInsightsRequest) (TemplateInsightsResponse, error) {
Expand Down
7 changes: 5 additions & 2 deletions site/src/api/typesGenerated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.