Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8a1d3ee
feat(coderd): add user latency and template insights endpoints
mafredri Jul 14, 2023
b31ec33
feat(coderd): implement user latency insights logic
mafredri Jul 18, 2023
aaadc6a
feat(coderd): implement template insights logic
mafredri Jul 19, 2023
b54b0aa
make start/endtime check more strict
mafredri Jul 19, 2023
5f2bfd4
move interval verification
mafredri Jul 19, 2023
4820c53
gen
mafredri Jul 20, 2023
6326643
allow endtime for today include the hour
mafredri Jul 20, 2023
2198c5f
prevent timetravel
mafredri Jul 20, 2023
2e51056
add test for latencies
mafredri Jul 20, 2023
ddc8606
add test for template insights
mafredri Jul 20, 2023
26e0f02
Merge branch 'main' into mafredri/feat-coderd-add-user-latency-and-in…
mafredri Jul 20, 2023
2c8e311
verify same timezone for start/end
mafredri Jul 20, 2023
917997b
fix typo in query comment and improve comments
mafredri Jul 21, 2023
e5b96d4
fix generic internal server error
mafredri Jul 21, 2023
87b1b90
s/greater/after/
mafredri Jul 21, 2023
bffc673
unexport insights time layout
mafredri Jul 21, 2023
056918e
remove interval none
mafredri Jul 21, 2023
d5a9865
remove mixed tz restrictions, test DST
mafredri Jul 21, 2023
088620e
fix lint
mafredri Jul 21, 2023
397cc7a
add fixmes to dbauthz
mafredri Jul 21, 2023
ebacfe1
improve comment about assert equality
mafredri Jul 21, 2023
cd07478
replace sleep with cat
mafredri Jul 21, 2023
040390d
add bad request tests
mafredri Jul 21, 2023
b1de87f
fix comment placement
mafredri Jul 21, 2023
5588e39
create convert function for builtin apps
mafredri Jul 21, 2023
dafbba1
move interval loop
mafredri Jul 21, 2023
fc2157d
remove all users, improve test comments
mafredri Jul 21, 2023
7fd13df
Merge branch 'main' into mafredri/feat-coderd-add-user-latency-and-in…
mafredri Jul 21, 2023
9e228f6
Merge branch 'main' into mafredri/feat-coderd-add-user-latency-and-in…
mafredri Jul 21, 2023
b03cc29
fix windows test?
mafredri Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove interval none
  • Loading branch information
mafredri committed Jul 21, 2023
commit 056918ec969ff82748a07401ad7e86745af5626d
9 changes: 1 addition & 8 deletions coderd/apidoc/docs.go

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

14 changes: 3 additions & 11 deletions coderd/apidoc/swagger.json

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

8 changes: 4 additions & 4 deletions coderd/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (api *API) insightsTemplates(rw http.ResponseWriter, r *http.Request) {
// to parse the time ourselves.
startTimeString = p.String(vals, "", "start_time")
endTimeString = p.String(vals, "", "end_time")
intervalString = p.String(vals, string(codersdk.InsightsReportIntervalNone), "interval")
intervalString = p.String(vals, "", "interval")
templateIDs = p.UUIDs(vals, []uuid.UUID{}, "template_ids")
)
p.ErrorExcessParams(vals)
Expand Down Expand Up @@ -224,7 +224,7 @@ func (api *API) insightsTemplates(rw http.ResponseWriter, r *http.Request) {
err := api.Database.InTx(func(db database.Store) error {
var err error

if interval != codersdk.InsightsReportIntervalNone {
if interval != "" {
dailyUsage, err = db.GetTemplateDailyInsights(ctx, database.GetTemplateDailyInsightsParams{
StartTime: startTime,
EndTime: endTime,
Expand Down Expand Up @@ -435,15 +435,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, codersdk.InsightsReportIntervalNone:
case codersdk.InsightsReportIntervalDay, "":
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.InsightsReportIntervalNone, codersdk.InsightsReportIntervalDay}),
Detail: fmt.Sprintf("must be one of %v", []codersdk.InsightsReportInterval{codersdk.InsightsReportIntervalDay}),
},
},
})
Expand Down
7 changes: 3 additions & 4 deletions codersdk/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ type InsightsReportInterval string

// InsightsReportInterval enums.
const (
InsightsReportIntervalNone InsightsReportInterval = "none"
InsightsReportIntervalDay InsightsReportInterval = "day"
InsightsReportIntervalDay InsightsReportInterval = "day"
)

// UserLatencyInsightsResponse is the response from the user latency insights
Expand Down Expand Up @@ -109,7 +108,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" example:"day"`
Interval InsightsReportInterval `json:"interval"`
ActiveUsers int64 `json:"active_users" example:"14"`
}

Expand Down Expand Up @@ -157,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" example:"day"`
Interval InsightsReportInterval `json:"interval"`
}

func (c *Client) TemplateInsights(ctx context.Context, req TemplateInsightsRequest) (TemplateInsightsResponse, error) {
Expand Down
9 changes: 4 additions & 5 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -2914,17 +2914,16 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
## codersdk.InsightsReportInterval

```json
"none"
"day"
```

### Properties

#### Enumerated Values

| Value |
| ------ |
| `none` |
| `day` |
| Value |
| ----- |
| `day` |

## codersdk.IssueReconnectingPTYSignedTokenRequest

Expand Down
4 changes: 2 additions & 2 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1590,8 +1590,8 @@ export const GitProviders: GitProvider[] = [
]

// From codersdk/insights.go
export type InsightsReportInterval = "day" | "none"
export const InsightsReportIntervals: InsightsReportInterval[] = ["day", "none"]
export type InsightsReportInterval = "day"
export const InsightsReportIntervals: InsightsReportInterval[] = ["day"]

// From codersdk/provisionerdaemons.go
export type JobErrorCode =
Expand Down