Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b36ffa

Browse files
committed
fix user-activity response on no rows
1 parent4e36a62 commit3b36ffa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎coderd/insights.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package coderd
22

33
import (
44
"context"
5+
"database/sql"
56
"fmt"
67
"net/http"
78
"strings"
@@ -102,6 +103,19 @@ func (api *API) insightsUserActivity(rw http.ResponseWriter, r *http.Request) {
102103
TemplateIDs:templateIDs,
103104
})
104105
iferr!=nil {
106+
// No data is not an error.
107+
ifxerrors.Is(err,sql.ErrNoRows) {
108+
httpapi.Write(ctx,rw,http.StatusOK, codersdk.UserActivityInsightsResponse{
109+
Report: codersdk.UserActivityInsightsReport{
110+
StartTime:startTime,
111+
EndTime:endTime,
112+
TemplateIDs: []uuid.UUID{},
113+
Users: []codersdk.UserActivity{},
114+
},
115+
})
116+
return
117+
}
118+
// Check authorization.
105119
ifhttpapi.Is404Error(err) {
106120
httpapi.ResourceNotFound(rw)
107121
return

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp