Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(coderd): add avatar URL to the users' latency endpoint #8701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions coderd/apidoc/docs.go

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

4 changes: 4 additions & 0 deletions coderd/apidoc/swagger.json

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

1 change: 1 addition & 0 deletions coderd/database/dbfake/dbfake.go
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,7 @@ func (q *FakeQuerier) GetUserLatencyInsights(_ context.Context, arg database.Get
row := database.GetUserLatencyInsightsRow{
UserID: userID,
Username: user.Username,
AvatarURL: user.AvatarURL,
TemplateIDs: templateIDs,
WorkspaceConnectionLatency50: tryPercentile(latencies, 50),
WorkspaceConnectionLatency95: tryPercentile(latencies, 95),
Expand Down
15 changes: 9 additions & 6 deletions coderd/database/queries.sql.go

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

3 changes: 2 additions & 1 deletion coderd/database/queries/insights.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
SELECT
workspace_agent_stats.user_id,
users.username,
users.avatar_url,
array_agg(DISTINCT template_id)::uuid[] AS template_ids,
coalesce((PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY connection_median_latency_ms)), -1)::FLOAT AS workspace_connection_latency_50,
coalesce((PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY connection_median_latency_ms)), -1)::FLOAT AS workspace_connection_latency_95
Expand All @@ -17,7 +18,7 @@ WHERE
AND workspace_agent_stats.connection_median_latency_ms > 0
AND workspace_agent_stats.connection_count > 0
AND CASE WHEN COALESCE(array_length(@template_ids::uuid[], 1), 0) > 0 THEN template_id = ANY(@template_ids::uuid[]) ELSE TRUE END
GROUP BY workspace_agent_stats.user_id, users.username
GROUP BY workspace_agent_stats.user_id, users.username, users.avatar_url
ORDER BY user_id ASC;

-- name: GetTemplateInsights :one
Expand Down
1 change: 1 addition & 0 deletions coderd/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (api *API) insightsUserLatency(rw http.ResponseWriter, r *http.Request) {
TemplateIDs: row.TemplateIDs,
UserID: row.UserID,
Username: row.Username,
AvatarURL: row.AvatarURL.String,
LatencyMS: codersdk.ConnectionLatency{
P50: row.WorkspaceConnectionLatency50,
P95: row.WorkspaceConnectionLatency95,
Expand Down
1 change: 1 addition & 0 deletions codersdk/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type UserLatency struct {
TemplateIDs []uuid.UUID `json:"template_ids" format:"uuid"`
UserID uuid.UUID `json:"user_id" format:"uuid"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url" format:"uri"`
LatencyMS ConnectionLatency `json:"latency_ms"`
}

Expand Down
1 change: 1 addition & 0 deletions docs/api/insights.md

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

4 changes: 4 additions & 0 deletions docs/api/schemas.md

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

1 change: 1 addition & 0 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ export interface UserLatency {
readonly template_ids: string[]
readonly user_id: string
readonly username: string
readonly avatar_url: string
readonly latency_ms: ConnectionLatency
}

Expand Down