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

Commit20a3801

Browse files
authored
fix: use floats in report template (#14714)
1 parentfccf6f1 commit20a3801

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

‎cli/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
10211021
notificationsManager.Run(dbauthz.AsSystemRestricted(ctx))
10221022

10231023
// Run report generator to distribute periodic reports.
1024-
notificationReportGenerator:=reports.NewReportGenerator(ctx,logger,options.Database,options.NotificationsEnqueuer,quartz.NewReal())
1024+
notificationReportGenerator:=reports.NewReportGenerator(ctx,logger.Named("notifications.report_generator"),options.Database,options.NotificationsEnqueuer,quartz.NewReal())
10251025
defernotificationReportGenerator.Close()
10261026
}
10271027

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
UPDATE notification_templates
2+
SET
3+
body_template= REPLACE(body_template::text,'{{if gt $version.failed_count 1.0}}','{{if gt $version.failed_count 1}}')::text
4+
WHERE
5+
id='34a20db2-e9cc-4a93-b0e4-8569699d7a00';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
UPDATE notification_templates
2+
SET
3+
body_template= REPLACE(body_template::text,'{{if gt $version.failed_count 1}}','{{if gt $version.failed_count 1.0}}')::text
4+
WHERE
5+
id='34a20db2-e9cc-4a93-b0e4-8569699d7a00';

‎coderd/notifications/notifications_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -853,40 +853,41 @@ func TestNotificationTemplatesCanRender(t *testing.T) {
853853
"template_name":"bobby-first-template",
854854
"template_display_name":"Bobby First Template",
855855
},
856+
// We need to use floats as `json.Unmarshal` unmarshal numbers in `map[string]any` to floats.
856857
Data:map[string]any{
857-
"failed_builds":4,
858-
"total_builds":55,
858+
"failed_builds":4.0,
859+
"total_builds":55.0,
859860
"report_frequency":"week",
860861
"template_versions": []map[string]any{
861862
{
862863
"template_version_name":"bobby-template-version-1",
863-
"failed_count":3,
864+
"failed_count":3.0,
864865
"failed_builds": []map[string]any{
865866
{
866867
"workspace_owner_username":"mtojek",
867868
"workspace_name":"workspace-1",
868-
"build_number":1234,
869+
"build_number":1234.0,
869870
},
870871
{
871872
"workspace_owner_username":"johndoe",
872873
"workspace_name":"my-workspace-3",
873-
"build_number":5678,
874+
"build_number":5678.0,
874875
},
875876
{
876877
"workspace_owner_username":"jack",
877878
"workspace_name":"workwork",
878-
"build_number":774,
879+
"build_number":774.0,
879880
},
880881
},
881882
},
882883
{
883884
"template_version_name":"bobby-template-version-2",
884-
"failed_count":1,
885+
"failed_count":1.0,
885886
"failed_builds": []map[string]any{
886887
{
887888
"workspace_owner_username":"ben",
888889
"workspace_name":"cool-workspace",
889-
"build_number":8888,
890+
"build_number":8888.0,
890891
},
891892
},
892893
},

‎coderd/notifications/reports/generator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func NewReportGenerator(ctx context.Context, logger slog.Logger, db database.Sto
7575
return
7676
casetick:=<-ticker.C:
7777
ticker.Stop()
78+
7879
doTick(dbtime.Time(tick).UTC())
7980
}
8081
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp