Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add some handling to create an analysis details link in emails #16

Merged
merged 2 commits into from
Oct 2, 2024
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this isn't being used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right. I was going to add this as a fallback in case we don't have an analysis ID. I'll add that to the template now.

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" . }}