Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

2.1.2 release #110

Merged
merged 4 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.14.2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "msupply-foundation-excel-report-email-scheduler",
"version": "2.1.1",
"version": "2.1.2",
"description": "Grafana plugin for mSupply Dashboard application. The plugin takes data from panels of mSupply dashboard to generate excel reports. The reports are then emailed to a custom user group created with mSupply users pulled from mSupply Dashboard's datasource. The timing of the scheduler can be set in the plugin.",
"scripts": {
"build": "rm -rf dist && yarn build:frontend && mage -v && yarn sign",
Expand Down
18 changes: 14 additions & 4 deletions pkg/datasource/schedule_with_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,21 @@ func (schedule *Schedule) UpdateNextReportTime() {
reportTime = reportTime.AddDate(0, 1, daysOffset)
}
case 2: // fortnightly
daysToAdd := (scheduleDays - int(reportTime.Day()) + 14) % 14
reportTime = reportTime.AddDate(0, 0, daysToAdd)
if scheduleDays == int(reportTime.Weekday()) {
reportTime = reportTime.AddDate(0, 0, 14)
} else {
daysToAdd := (scheduleDays - int(reportTime.Day()) + 14) % 14
reportTime = reportTime.AddDate(0, 0, daysToAdd)
}

case 1: // weekly
daysToAdd := (scheduleDays - int(reportTime.Weekday()) + 7) % 7
reportTime = reportTime.AddDate(0, 0, daysToAdd)
if scheduleDays == int(reportTime.Weekday()) {
reportTime = reportTime.AddDate(0, 0, 7)
} else {
daysToAdd := (scheduleDays - int(reportTime.Weekday()) + 7) % 7
reportTime = reportTime.AddDate(0, 0, daysToAdd)
}

default: // 0 == daily
if reportTime.Unix() < now.Unix() {
// run tomorrow
Expand Down