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

Commitbf218e9

Browse files
committed
uniq
1 parent05d7a2c commitbf218e9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

‎coderd/database/dbfake/dbfake.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,21 @@ func isNotNull(v interface{}) bool {
562562
// these methods remain unimplemented in the FakeQuerier.
563563
varErrUnimplemented=xerrors.New("unimplemented")
564564

565+
funcuniqueSortedUUIDs(uuids []uuid.UUID) []uuid.UUID {
566+
set:=make(map[uuid.UUID]struct{})
567+
for_,id:=rangeuuids {
568+
set[id]=struct{}{}
569+
}
570+
unique:=make([]uuid.UUID,0,len(set))
571+
forid:=rangeset {
572+
unique=append(unique,id)
573+
}
574+
slices.SortFunc(unique,func(a,b uuid.UUID)bool {
575+
returna.String()<b.String()
576+
})
577+
returnunique
578+
}
579+
565580
func (*FakeQuerier)AcquireLock(_ context.Context,_int64)error {
566581
returnxerrors.New("AcquireLock must only be called within a transaction")
567582
}
@@ -2147,7 +2162,7 @@ func (q *FakeQuerier) GetTemplateParameterInsights(ctx context.Context, arg data
21472162
forvalue,count:=rangecounts[key] {
21482163
rows=append(rows, database.GetTemplateParameterInsightsRow{
21492164
Num:utp.Num,
2150-
TemplateIDs:utp.TemplateIDs,
2165+
TemplateIDs:uniqueSortedUUIDs(utp.TemplateIDs),
21512166
Name:utp.Name,
21522167
DisplayName:utp.DisplayName,
21532168
Description:utp.Description,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp