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

fix(coderd): humanize duration on notifications#14333

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 4 commits intomainfrombq/fix-dormant-notification
Aug 19, 2024

Conversation

BrunoQuaresma
Copy link
Collaborator

Close#14325

I added tests for the Humanize function, but we might want to consider adding snapshot tests for the notifications in the near future.

Since these tests would require a database (as the templates are stored there), it can be challenging to update the golden files locally with our current test setup. I’m wondering if we should start considering the use of an embedded database for some tests. 🤔

Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Almost there, please address CI issues.

Comment on lines 9 to 11
func Humanize(d time.Duration) string {
endTime := time.Now().Add(d)
return humanize.Time(endTime)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Given this is only used in two places, I'm not convinced we need any indirection in front ofhumanize.Time; we should just use it directly.

If we were using this very broadly, I could see some value is hiding this behind our own interface so we could swap out the underlying implementation, but I don't think we're there yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Happy you noticed this to reduce abstraction!

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

100%, I was just too lazy to remove the first abstraction I added. My bad 🙏

kylecarbs reacted with hooray emoji
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Couple minor thoughts but LGTM!

BrunoQuaresma reacted with heart emoji
@@ -323,14 +324,15 @@ func (e *Executor) runOnce(t time.Time) Stats {
}
}
if shouldNotifyDormancy {
dormantTime := time.Now().Add(time.Duration(tmpl.TimeTilDormant))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

One thing to check: is the dormancy value in the database in UTC? If so, the timezone of the control plane might make things weird and we may want to add a.UTC() call in here too or usedbtime.Now()

BrunoQuaresma reacted with thumbs up emoji
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good to know

@@ -691,7 +691,7 @@ func TestNotificationTemplatesCanRender(t *testing.T) {
"reason": "breached the template's threshold for inactivity",
"initiator": "autobuild",
"dormancyHours": "24",
"timeTilDormant": "24h",
"timeTilDormant": "24 hours",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A test which includes not such a round number would also be helpful for illustrative purposes.

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Added

@BrunoQuaresmaBrunoQuaresma merged commit10327fb intomainAug 19, 2024
27 checks passed
@BrunoQuaresmaBrunoQuaresma deleted the bq/fix-dormant-notification branchAugust 19, 2024 18:49
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 19, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

@kylecarbskylecarbsAwaiting requested review from kylecarbs

Assignees

@BrunoQuaresmaBrunoQuaresma

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Humanize the duration time in the dormant notification email
3 participants
@BrunoQuaresma@dannykopping@kylecarbs

[8]ページ先頭

©2009-2025 Movatter.jp