Skip to content

Commit a7f2426

Browse files
committed
Add collab URL to notification e-mail
1 parent 2498b7c commit a7f2426

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

simqueue/api/resources.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,23 @@ def _send_email(self, bundle):
248248
logger.warning("Multiple users found with the same oidc id.")
249249
if email:
250250
logger.info("Sending e-mail about job #{} to {}".format(str(bundle.data['id']), bundle.request.user.email))
251-
logs_list = Log.objects.filter(pk=bundle.data['id'])
252-
if len(logs_list) == 0:
253-
logs_content = " "
251+
log_list = Log.objects.filter(pk=bundle.data['id'])
252+
if log_list.count() == 0:
253+
log_content = ""
254254
else:
255-
logs_lines = logs_list[0].content.split("\n")
256-
nb_lines = len(logs_lines)
257-
logs_content = ""
258-
for (i, item) in enumerate(logs_lines):
259-
if (i == 11):
260-
logs_content = logs_content + "\n" + "..................."
261-
if (i < 10) | (i>=(nb_lines-10)):
262-
logs_content = logs_content + "\n" +item
263-
subject = 'NMPI: job ' + str(bundle.data['id']) + ' ' + bundle.data['status']
264-
content = subject + "\n" + str(logs_content)
255+
log_lines = log_list[0].content.split("\n")
256+
nb_lines = len(log_lines)
257+
if nb_lines <= 20:
258+
log_content = "\n".join(log_lines[:20])
259+
else:
260+
log_content = "\n".join(log_lines[:10])
261+
log_content += "\n\n. . .\n\n"
262+
log_content += "\n".join(log_lines[-10:])
263+
subject = '[HBP Neuromorphic] job ' + str(bundle.data['id']) + ' ' + bundle.data['status']
264+
content = 'HBP Neuromorphic Computing Platform: Job {} {}\n\n'.format(bundle.data['id'],
265+
bundle.data['status'])
266+
content += "https://collab.humanbrainproject.eu/#/collab/{}\n\n".format(bundle.data['collab_id'])
267+
content += log_content
265268
try:
266269
send_mail(
267270
subject,

0 commit comments

Comments
 (0)