Skip to content

Commit 176051a

Browse files
committed
review notes
1 parent e0f1609 commit 176051a

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

coderd/database/querier_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,10 +2321,6 @@ func TestGetUserStatusCountsOverTime(t *testing.T) {
23212321
name: "Suspended Only",
23222322
status: database.UserStatusSuspended,
23232323
},
2324-
// {
2325-
// name: "Deleted Only",
2326-
// status: database.UserStatusDeleted,
2327-
// },
23282324
}
23292325

23302326
for _, tc := range testCases {

coderd/database/queries.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/insights.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ ranked_status_change_per_user_per_date AS (
873873
LEFT JOIN relevant_status_changes rsc1 ON rsc1.changed_at <= d.date
874874
)
875875
SELECT
876-
date,
876+
rscpupd.date,
877877
statuses.new_status AS status,
878878
COUNT(rscpupd.user_id) FILTER (
879879
WHERE rscpupd.rn = 1

coderd/insights.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ func (api *API) insightsUserStatusCountsOverTime(rw http.ResponseWriter, r *http
329329
EndTime: nextHourInLoc,
330330
})
331331
if err != nil {
332+
if httpapi.IsUnauthorizedError(err) {
333+
httpapi.Forbidden(rw)
334+
return
335+
}
332336
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
333337
Message: "Internal error fetching user status counts over time.",
334338
Detail: err.Error(),
@@ -342,9 +346,6 @@ func (api *API) insightsUserStatusCountsOverTime(rw http.ResponseWriter, r *http
342346

343347
for _, row := range rows {
344348
status := codersdk.UserStatus(row.Status)
345-
if _, ok := resp.StatusCounts[status]; !ok {
346-
resp.StatusCounts[status] = make([]codersdk.UserStatusChangeCount, 0)
347-
}
348349
resp.StatusCounts[status] = append(resp.StatusCounts[status], codersdk.UserStatusChangeCount{
349350
Date: row.Date,
350351
Count: row.Count,

0 commit comments

Comments
 (0)