From 519d58ab20b09f31781dd07f7c22aed3004c56e1 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Tue, 1 Oct 2024 12:01:18 -0700 Subject: [PATCH 1/2] Add some handling to create an analysis details link in emails --- formatMessage.go | 10 +++++++++- templates/html/analysis_periodic_notification.tmpl | 1 + templates/html/analysis_status_change.tmpl | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/formatMessage.go b/formatMessage.go index 456d5d5..ea678dd 100644 --- a/formatMessage.go +++ b/formatMessage.go @@ -83,6 +83,7 @@ func FormatMessage(ctx context.Context, emailReq EmailRequest, payload map[strin payload["DEToolsLink"] = deSettings.base + deSettings.tools payload["DECollectionsLink"] = deSettings.base + deSettings.collections payload["DEAppsLink"] = deSettings.base + deSettings.apps + payload["DEAnalysesLink"] = deSettings.base + deSettings.analyses payload["DEPublicationRequestsLink"] = deSettings.base + deSettings.admin + deSettings.apps payload["DEPidRequestLink"] = deSettings.base + deSettings.admin + deSettings.doi @@ -105,7 +106,7 @@ func FormatMessage(ctx context.Context, emailReq EmailRequest, payload map[strin switch emailReq.Template { case "analysis_status_change", "analysis_periodic_notification": - var startDateText, resultFolderPath string + var startDateText, resultFolderPath, analysisId string // Format the analysis start date. err = ExtractDetails(payload, &startDateText, "startdate") @@ -127,6 +128,13 @@ func FormatMessage(ctx context.Context, emailReq EmailRequest, payload map[strin } payload["DEOutputFolderLink"] = deSettings.base + deSettings.data + resultFolderPath + // Format the link to the analysis details page + err = ExtractDetails(payload, &analysisId, "analysisid") + if err != nil { + log.Errorf("unable to extract the analysis ID: %s", err) + } + payload["DEAnalysisDetailsLink"] = deSettings.base + deSettings.analyses + "/" + analysisId + case "added_to_team": var teamName string err = ExtractDetails(payload, &teamName, "team_name") diff --git a/templates/html/analysis_periodic_notification.tmpl b/templates/html/analysis_periodic_notification.tmpl index 141265e..56c9ec8 100644 --- a/templates/html/analysis_periodic_notification.tmpl +++ b/templates/html/analysis_periodic_notification.tmpl @@ -3,6 +3,7 @@

The analysis {{.analysisname}} is still running and has been running for {{.runduration}}{{ if .endduration }}, and will stop in {{.endduration}}{{ end }}. This is an auto-scheduled courtesy reminder to help you manage your compute quota.

Analysis launch date: {{.startdate}}

+{{if .DEAnalysisDetailsLink}}

Terminate or extend your time limit: {{.DEAnalysisDetailsLink}}

{{- end}} {{if .access_url}}

Access your VICE analysis: {{.access_url}}

{{- end}} {{ if or (eq .analysisstatus "Completed") (eq .analysisstatus "Failed")}}

Results folder: {{.analysisresultsfolder}}

{{- end}} diff --git a/templates/html/analysis_status_change.tmpl b/templates/html/analysis_status_change.tmpl index 26123e7..2612f06 100644 --- a/templates/html/analysis_status_change.tmpl +++ b/templates/html/analysis_status_change.tmpl @@ -6,7 +6,8 @@ {{.analysisdescription}}

Analysis launch date: {{.startdate}}

+{{if .DEAnalysisDetailsLink}}

Analysis Details: {{.DEAnalysisDetailsLink}}

{{- end}} {{if .access_url}}

Access your VICE analysis: {{.access_url}}

{{- end}} {{ if or (eq .analysisstatus "Completed") (eq .analysisstatus "Failed")}}

Results folder: {{.analysisresultsfolder}}

{{- end}} -{{ template "footer" . }} \ No newline at end of file +{{ template "footer" . }} From 865a9f213a1b287dc1fefae3278de07ac4bb0172 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Wed, 2 Oct 2024 10:14:54 -0700 Subject: [PATCH 2/2] Use fallback link in case we don't have an analysis ID --- templates/html/analysis_periodic_notification.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/html/analysis_periodic_notification.tmpl b/templates/html/analysis_periodic_notification.tmpl index 56c9ec8..fffdc8f 100644 --- a/templates/html/analysis_periodic_notification.tmpl +++ b/templates/html/analysis_periodic_notification.tmpl @@ -3,7 +3,7 @@

The analysis {{.analysisname}} is still running and has been running for {{.runduration}}{{ if .endduration }}, and will stop in {{.endduration}}{{ end }}. This is an auto-scheduled courtesy reminder to help you manage your compute quota.

Analysis launch date: {{.startdate}}

-{{if .DEAnalysisDetailsLink}}

Terminate or extend your time limit: {{.DEAnalysisDetailsLink}}

{{- end}} +

Terminate or extend your time limit: {{if .DEAnalysisDetailsLink}}{{.DEAnalysisDetailsLink}}{{ else }}{{ .DEAnalysesLink }}{{ end }}

{{if .access_url}}

Access your VICE analysis: {{.access_url}}

{{- end}} {{ if or (eq .analysisstatus "Completed") (eq .analysisstatus "Failed")}}

Results folder: {{.analysisresultsfolder}}

{{- end}}