From 064bcd4d878f9408002786f792ec185836f15946 Mon Sep 17 00:00:00 2001 From: anildahalsussol Date: Tue, 24 Jan 2023 13:33:11 +0545 Subject: [PATCH 1/3] #107 Schedular Frequently sending emails Update date to send email. --- pkg/datasource/schedule_with_details.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/datasource/schedule_with_details.go b/pkg/datasource/schedule_with_details.go index 3ac1cef..67bd325 100644 --- a/pkg/datasource/schedule_with_details.go +++ b/pkg/datasource/schedule_with_details.go @@ -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 From f55b3c7649f50106f9840f6bea4a3a9044f9403c Mon Sep 17 00:00:00 2001 From: Sworup Shakya Date: Wed, 25 Jan 2023 11:24:46 +0545 Subject: [PATCH 2/3] Create .tool-versions --- .tool-versions | 1 + 1 file changed, 1 insertion(+) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..0094556 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nodejs 16.14.2 From d7853f0cc57f8b25afcc0a6824ef8182b9aea605 Mon Sep 17 00:00:00 2001 From: Sworup Shakya Date: Wed, 25 Jan 2023 11:31:31 +0545 Subject: [PATCH 3/3] Bump up version to 2.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bce7ba9..05c0c25 100644 --- a/package.json +++ b/package.json @@ -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",