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

Commit6813b73

Browse files
committed
fix dbmem query logic replication
1 parentf3bc067 commit6813b73

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

‎coderd/database/dbmem/dbmem.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,7 +3058,7 @@ func (q *FakeQuerier) GetTemplateAppInsights(ctx context.Context, arg database.G
30583058
// FROM
30593059
for_,stat:=rangeq.templateUsageStats {
30603060
// WHERE
3061-
ifstat.StartTime.Before(arg.StartTime)||stat.StartTime.After(arg.EndTime) {
3061+
ifstat.StartTime.Before(arg.StartTime)||stat.EndTime.After(arg.EndTime) {
30623062
continue
30633063
}
30643064
iflen(arg.TemplateIDs)>0&&!slices.Contains(arg.TemplateIDs,stat.TemplateID) {
@@ -3118,20 +3118,20 @@ func (q *FakeQuerier) GetTemplateAppInsights(ctx context.Context, arg database.G
31183118
}
31193119

31203120
templateRows:=make(map[appGroupBy]templateRow)
3121-
for_,row:=rangeappInsightRows {
3121+
for_,aiRow:=rangeappInsightRows {
31223122
key:=appGroupBy{
3123-
AppName:row.AppName,
3124-
DisplayName:row.DisplayName,
3125-
Icon:row.Icon,
3126-
IsApp:row.IsApp,
3123+
AppName:aiRow.AppName,
3124+
DisplayName:aiRow.DisplayName,
3125+
Icon:aiRow.Icon,
3126+
IsApp:aiRow.IsApp,
31273127
}
31283128
row,ok:=templateRows[key]
31293129
if!ok {
31303130
row=templateRow{
31313131
appGroupBy:key,
31323132
}
31333133
}
3134-
row.TemplateIDs=append(row.TemplateIDs,row.TemplateIDs...)
3134+
row.TemplateIDs=uniqueSortedUUIDs(append(row.TemplateIDs,aiRow.TemplateIDs...))
31353135
templateRows[key]=row
31363136
}
31373137

@@ -3171,18 +3171,20 @@ func (q *FakeQuerier) GetTemplateAppInsights(ctx context.Context, arg database.G
31713171
IsApp:aiRow.IsApp,
31723172
}
31733173
row:=groupedRows[key]
3174-
row.TemplateIDs=append(row.TemplateIDs,aiRow.TemplateIDs...)
31753174
row.ActiveUserIDs=append(row.ActiveUserIDs,aiRow.UserID)
31763175
row.UsageSeconds+=aiRow.AppUsageMins*60
3176+
groupedRows[key]=row
31773177
}
31783178

31793179
varrows []database.GetTemplateAppInsightsRow
3180-
fork,gr:=rangegroupedRows {
3180+
forkey,gr:=rangegroupedRows {
31813181
rows=append(rows, database.GetTemplateAppInsightsRow{
3182-
TemplateIDs:uniqueSortedUUIDs(gr.TemplateIDs),
3182+
TemplateIDs:templateRows[key].TemplateIDs,
31833183
ActiveUsers:int64(len(uniqueSortedUUIDs(gr.ActiveUserIDs))),
3184-
DisplayName:k.DisplayName,
3185-
SlugOrPort:k.AppName,
3184+
SlugOrPort:key.AppName,
3185+
DisplayName:key.DisplayName,
3186+
Icon:key.Icon,
3187+
IsApp:key.IsApp,
31863188
UsageSeconds:gr.UsageSeconds,
31873189
})
31883190
}
@@ -8354,7 +8356,7 @@ func (q *FakeQuerier) UpsertTemplateUsageStats(ctx context.Context) error {
83548356
returnerr
83558357
}
83568358
// CROSS JOIN generate_series
8357-
fort:=was.SessionStartedAt;t.Before(was.SessionEndedAt);t=t.Add(time.Minute) {
8359+
fort:=was.SessionStartedAt.Truncate(time.Minute);t.Before(was.SessionEndedAt);t=t.Add(time.Minute) {
83588360
// WHERE
83598361
ift.Before(latestStart)||t.After(now)||t.Equal(now) {
83608362
continue

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp