Skip to content

Commit

Permalink
Merge pull request #16 from ianmcorvidae/analysis-details-link
Browse files Browse the repository at this point in the history
Add some handling to create an analysis details link in emails
  • Loading branch information
ianmcorvidae authored Oct 2, 2024
2 parents 986527c + 865a9f2 commit 90138b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion formatMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions templates/html/analysis_periodic_notification.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<p>The analysis <b>{{.analysisname}}</b> is still running and has been running for <b>{{.runduration}}</b>{{ if .endduration }}, and will stop in <b>{{.endduration}}</b>{{ end }}. This is an auto-scheduled courtesy reminder to help you manage your compute quota.</p>

<p><b>Analysis launch date:</b> {{.startdate}}</p>
<p><b>Terminate or extend your time limit:</b> {{if .DEAnalysisDetailsLink}}{{.DEAnalysisDetailsLink}}{{ else }}{{ .DEAnalysesLink }}{{ end }}</p>
{{if .access_url}}<p><b>Access your VICE analysis:</b> {{.access_url}}</p>{{- end}}
{{ if or (eq .analysisstatus "Completed") (eq .analysisstatus "Failed")}} <p><b>Results folder:</b> <a href="{{.DEOutputFolderLink}}" target="_blank">{{.analysisresultsfolder}}</a></p>{{- end}}

Expand Down
3 changes: 2 additions & 1 deletion templates/html/analysis_status_change.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
{{.analysisdescription}}
</p>
<p><b>Analysis launch date:</b> {{.startdate}}</p>
{{if .DEAnalysisDetailsLink}}<p><b>Analysis Details:</b> {{.DEAnalysisDetailsLink}}</p>{{- end}}
{{if .access_url}}<p><b>Access your VICE analysis:</b> {{.access_url}}</p>{{- end}}
{{ if or (eq .analysisstatus "Completed") (eq .analysisstatus "Failed")}} <p><b>Results folder:</b> <a href="{{.DEOutputFolderLink}}" target="_blank">{{.analysisresultsfolder}}</a></p>{{- end}}

{{ template "footer" . }}
{{ template "footer" . }}

0 comments on commit 90138b6

Please sign in to comment.