Skip to content
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

feat: save history of notification sends #557

Merged
merged 6 commits into from
Sep 19, 2023

Conversation

adityathebe
Copy link
Member

Resolves: #553

notification/context.go Outdated Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
jobs/jobs.go Outdated
@@ -63,6 +66,16 @@ func Start() {
logger.Errorf("Failed to schedule job for cleaning up event queue table: %v", err)
}

if _, err := ScheduleFunc(CleanupNotificationSendHistorySchedule, func() {
if count, err := duty.DeleteNotificationSendHistory(api.NewContext(db.Gorm, nil), 30); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

nit: The logging of the results should probably be in the function itself, and we should be passing through a DbContext rather than db.Gorm

Copy link
Member Author

Choose a reason for hiding this comment

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

The logging of the results should probably be in the function itself

I am not sure if the duty func should be doing the logging.

we should be passing through a DbContext rather than db.Gorm

All of the jobs use db.Gorm directly and there's no DBContext at this stage yet. I guess we could pass gorm directly to the jobs starting function

func Start() {}

to

func Start(db *gorm.DB) {}

Copy link
Member

Choose a reason for hiding this comment

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

We should be using the DBContext exported by duty

I don't see why the logging shouldn't be done in duty, if we ever modify this function maybe to delete by type, or delete by errors, etc.. We would need to update the logic and the function return, publish and then update in incident commander.

We schedule the job from incident commander, just be cause duty is a pure library without global context, that doesn't mean the job details should leak into incident commander

notification/context.go Outdated Show resolved Hide resolved
@moshloop moshloop merged commit 3ee6c42 into main Sep 19, 2023
5 checks passed
@moshloop moshloop deleted the feat/notification-send-history branch September 19, 2023 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notifications | We need to somehow make the users aware of any failures that occur when sending notifications
2 participants