Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* prepare pending commitment job to queue mails * add mail_notification struct * add testenv * Add unit test for confirm job * fix linter * fix: add notify attribute to commitment db structure * pending: add a second commitment for the second testcase * Update internal/collector/capacity_scrape_test.go Co-authored-by: Stefan Majewsky <[email protected]> * tests: ignore first dbChange set * Update internal/core/config.go Co-authored-by: Stefan Majewsky <[email protected]> * Update internal/db/models.go Co-authored-by: Stefan Majewsky <[email protected]> * fix: next_submission_at attribute name commitment amount in the second test case * fix: createMailNotification now returns value instead of pointer * cluster: MailTemplate is now a struct mail template is now given as part of the cluster config * shorten CommitmentInfo to existing types shorten commitmentQuery by using the AZResourceLocation data * use conistent 'mail' naming * move template creation into cluster attribute * fix: make error message of failed template creation more clear * add mail_delivery_job skeleton * Add send mail job * fix: consistent table order on queue overlap * fix linter * fix license header * fix another license header * fix: add confirmed_at as ISO8601 date into the result set * add job for expiring commitments. Add TODOs * Add short-term commitment detection and unit tests * simplify key sorting for projectIDs * fix typo in comment * Add expiring mail job to collector task * update unit test comments update license headers to current year * expiring: set date after db query error check concluded add jitter to requery of failed mail deliveries * Update internal/collector/expiring_commitments.go Co-authored-by: Stefan Majewsky <[email protected]> * Update internal/collector/expiring_commitments.go Co-authored-by: Stefan Majewsky <[email protected]> * rename expiring commitment job. Add missing space to mock notification template * Update internal/collector/expiring_commitments.go Co-authored-by: Stefan Majewsky <[email protected]> * fix import in expiring commitments * declare mailinfo within its loop to avoid eventual value leak * Update internal/collector/expiring_commitments.go Co-authored-by: Stefan Majewsky <[email protected]> * Update internal/collector/mail_delivery.go Co-authored-by: Stefan Majewsky <[email protected]> * cluster: rename MailForms to mailTemplates * mail_delivery: inline mailrequest build function * mail_delivery: failed test case, expect a returned error * mail_delivery: change error interval from 24 hours to 2 minutes * inject client directly into processMailDeliveryTask * fix: expiring_commitments notice period Fix space in Duration attribute of test mail template * expiring_commitments: change discovery task to read only. Add short-term notified query into process task Fix: Bug that already notified commitments would be notified on another run Add a unit test for the case above * fix: make MailTemplate the mail method receiver. fix: add subject to mail configuration. fix: change naming scheme from MailInfo to CommitmentGroupNotification * fix: mail service client. Endpoint gets deliver via environment variable client type is a set value now change MailClient interface and implementation names and add documentation for those types * fix: capitalize mail_endpoint env * fix: grammar in comment * review: simplify PrepareMailNotification - make it private since it does not need to be public - load the entire ProjectCommitment object instead of just a few fields (loading everything is not very expensive, and not doing it feels odd) - fully prepare the mail instead of doing only half the work in the helper function * review: simplify how mail templates are compiled This is nominally more code, but the code in NewCluster() repeats itself less. * review: push task-specific setup into task function * review: simplify sort When suggesting slices.Collect() here earlier, I did not realize that the sort.Slice() does not do anything special. So this can be simplified further. * review: typo * review: avoid running the same query in a tight loop * review: remove ExpiringCommitments struct The inciting motivation here was to make the full ProjectCommitment object available to the template, like in e3daee2. This required splitting the discover phase into two separate queries, one for the commitment objects themselves and one for context joined from other tables. It then appeared natural to me to make the discover phase very lean and only load commitments there, and do all the remaining work in the processing phase. * review: Include MAIL_ENDPOINT env to the limes collector documentation. add godoc documentation for each public type, func, var * review: add documentation for the mail template config Also, upon further consideration, it is indeed weird that I wanted to have the mail endpoint coming in as an env var when the rest of the mail config is in the config file. So this commit groups everything together in the config file. --------- Co-authored-by: Stefan Majewsky <[email protected]>
- Loading branch information