From 8f26d81d4587877785bd56cdfe5bdfebd4cea716 Mon Sep 17 00:00:00 2001 From: Sworup Shakya Date: Wed, 25 Jan 2023 10:37:27 +0545 Subject: [PATCH 1/2] Update setups for haiti --- .tool-versions | 1 + config/grafana.ini | 5 +++++ package.json | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) 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 diff --git a/config/grafana.ini b/config/grafana.ini index e8b9fea..d657fba 100644 --- a/config/grafana.ini +++ b/config/grafana.ini @@ -8,3 +8,8 @@ app_mode = development [dashboards.json] enabled = true path = /var/lib/grafana/dashboards + +[auth.generic_oauth] +auth_url = http://localhost:8080/api/v4/oauth/ +token_url = http://localhost:8080/api/v4/oauth_access_token/ +api_url = http://localhost:8080/api/v4/oauth_userinfo/ diff --git a/package.json b/package.json index 395d728..d596deb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "msupply-foundation-excel-report-email-scheduler", - "version": "2.1.2-haiti-01", + "version": "2.1.2-haiti-02", "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", @@ -10,7 +10,7 @@ "typecheck": "tsc --noEmit", "lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .", "lint:fix": "yarn lint --fix", - "sign": "rm -rf ./dist/.DS_Store & grafana-toolkit plugin:sign --signatureType private --rootUrls https://demo-board.msupply.org:3000,https://png.msupply.org:3000,https://ci.msupply.org:3000,https://liberia.msupply.org:3000,https://tonga-vax.msupply.org:3000,https://timor.msupply.org:3000,http://localhost:3000,https://vanuatu-vax.msupply.org:3000,https://tokelau.msupply.org:3000,https://tonga.msupply.org:3000,https://who-demo.msupply.org:3000,https://msupply.health.gov.ws:3000,https://fijimoh.msupply.org:3000", + "sign": "rm -rf ./dist/.DS_Store & grafana-toolkit plugin:sign --signatureType private --rootUrls http://localhost:3000,http://172.16.5.157:3000", "start": "yarn dev:frontend" }, "author": "mSupply Foundation", From 49693710a02839dcc8d37ad0502f818da1c31637 Mon Sep 17 00:00:00 2001 From: anildahalsussol Date: Tue, 24 Jan 2023 13:33:11 +0545 Subject: [PATCH 2/2] #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 fdd0bc7..c53a33f 100644 --- a/pkg/datasource/schedule_with_details.go +++ b/pkg/datasource/schedule_with_details.go @@ -138,11 +138,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