-
Notifications
You must be signed in to change notification settings - Fork 894
fix(coderd): use stable sorting for insights and improve test coverage #9250
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
Changes from 29 commits
ffc7391
95ad848
d4d58cf
e4f901a
f333170
6fb49a9
e9a967e
9879462
fc1a98d
f14ddf6
8a60568
7d93d13
f9fdb47
54638b0
7b0ac4c
1e7d860
9d96052
930d7ef
07cdc0b
73367d1
c2a0496
b738799
79bdbf9
ce2bb78
0896439
5b4733a
3607a80
688e1d0
8c294d0
decbdfe
870aff1
75a96d7
e72e265
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2018,6 +2018,10 @@ func (q *FakeQuerier) GetTemplateAppInsights(ctx context.Context, arg database.G | |
return nil, err | ||
} | ||
|
||
if len(arg.TemplateIDs) > 0 && !slices.Contains(arg.TemplateIDs, w.TemplateID) { | ||
continue | ||
} | ||
|
||
app, _ := q.getWorkspaceAppByAgentIDAndSlugNoLock(ctx, database.GetWorkspaceAppByAgentIDAndSlugParams{ | ||
AgentID: s.AgentID, | ||
Slug: s.SlugOrPort, | ||
|
@@ -2095,6 +2099,8 @@ func (q *FakeQuerier) GetTemplateAppInsights(ctx context.Context, arg database.G | |
}) | ||
} | ||
|
||
// NOTE(mafredri): Add sorting if we decide on how to handle PostgreSQL collations. | ||
// ORDER BY access_method, slug_or_port, display_name, icon, is_app | ||
return rows, nil | ||
} | ||
|
||
|
@@ -2264,7 +2270,6 @@ func (q *FakeQuerier) GetTemplateDailyInsights(ctx context.Context, arg database | |
} | ||
ds.userSet[s.UserID] = struct{}{} | ||
ds.templateIDSet[s.TemplateID] = struct{}{} | ||
break | ||
} | ||
} | ||
|
||
|
@@ -2278,24 +2283,27 @@ func (q *FakeQuerier) GetTemplateDailyInsights(ctx context.Context, arg database | |
continue | ||
} | ||
|
||
w, err := q.getWorkspaceByIDNoLock(ctx, s.WorkspaceID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if len(arg.TemplateIDs) > 0 && !slices.Contains(arg.TemplateIDs, w.TemplateID) { | ||
continue | ||
} | ||
|
||
for _, ds := range dailyStats { | ||
// (was.session_started_at >= ts.from_ AND was.session_started_at < ts.to_) | ||
// OR (was.session_ended_at > ts.from_ AND was.session_ended_at < ts.to_) | ||
// OR (was.session_started_at < ts.from_ AND was.session_ended_at >= ts.to_) | ||
if !(((s.SessionStartedAt.After(arg.StartTime) || s.SessionStartedAt.Equal(arg.StartTime)) && s.SessionStartedAt.Before(arg.EndTime)) || | ||
(s.SessionEndedAt.After(arg.StartTime) && s.SessionEndedAt.Before(arg.EndTime)) || | ||
(s.SessionStartedAt.Before(arg.StartTime) && (s.SessionEndedAt.After(arg.EndTime) || s.SessionEndedAt.Equal(arg.EndTime)))) { | ||
if !(((s.SessionStartedAt.After(ds.startTime) || s.SessionStartedAt.Equal(ds.startTime)) && s.SessionStartedAt.Before(ds.endTime)) || | ||
(s.SessionEndedAt.After(ds.startTime) && s.SessionEndedAt.Before(ds.endTime)) || | ||
(s.SessionStartedAt.Before(ds.startTime) && (s.SessionEndedAt.After(ds.endTime) || s.SessionEndedAt.Equal(ds.endTime)))) { | ||
continue | ||
} | ||
|
||
w, err := q.getWorkspaceByIDNoLock(ctx, s.WorkspaceID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ds.userSet[s.UserID] = struct{}{} | ||
ds.templateIDSet[w.TemplateID] = struct{}{} | ||
break | ||
} | ||
} | ||
|
||
|
@@ -2430,7 +2438,8 @@ func (q *FakeQuerier) GetTemplateParameterInsights(ctx context.Context, arg data | |
if tvp.TemplateVersionID != tv.ID { | ||
continue | ||
} | ||
key := fmt.Sprintf("%s:%s:%s:%s", tvp.Name, tvp.DisplayName, tvp.Description, tvp.Options) | ||
// GROUP BY tvp.name, tvp.type, tvp.display_name, tvp.description, tvp.options | ||
key := fmt.Sprintf("%s:%s:%s:%s:%s", tvp.Name, tvp.Type, tvp.DisplayName, tvp.Description, tvp.Options) | ||
if _, ok := uniqueTemplateParams[key]; !ok { | ||
num++ | ||
uniqueTemplateParams[key] = &database.GetTemplateParameterInsightsRow{ | ||
|
@@ -2480,6 +2489,8 @@ func (q *FakeQuerier) GetTemplateParameterInsights(ctx context.Context, arg data | |
} | ||
} | ||
|
||
// NOTE(mafredri): Add sorting if we decide on how to handle PostgreSQL collations. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. out of curiosity: what is the default PostgreSQL behavior considering the "most default" configuration? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will depend on the systems locale. Essentially if e.g. if |
||
// ORDER BY utp.name, utp.type, utp.display_name, utp.description, utp.options, wbp.value | ||
return rows, nil | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.