diff --git a/session-manager/handlers/analytics.py b/session-manager/handlers/analytics.py index a7e41d2a..4d9f87bd 100644 --- a/session-manager/handlers/analytics.py +++ b/session-manager/handlers/analytics.py @@ -21,13 +21,6 @@ def send_event_to_webhook(url, message): def report_analytics_event(event, data={}): - message = None - - logging.info("Reporting analytics event %s with data %s.", event, data) - - if not ANALYTICS_WEBHOOK_URL: - return - message = { "event": { "name": event, @@ -36,5 +29,9 @@ def report_analytics_event(event, data={}): }, } - if message: - send_event_to_webhook(ANALYTICS_WEBHOOK_URL, message) + logging.info("Reporting analytics event %s as message %s.", event, message) + + if not ANALYTICS_WEBHOOK_URL: + return + + send_event_to_webhook(ANALYTICS_WEBHOOK_URL, message) diff --git a/training-portal/src/project/apps/workshops/manager/analytics.py b/training-portal/src/project/apps/workshops/manager/analytics.py index 886e5aca..0a5f621b 100644 --- a/training-portal/src/project/apps/workshops/manager/analytics.py +++ b/training-portal/src/project/apps/workshops/manager/analytics.py @@ -19,11 +19,6 @@ def send_event_to_webhook(url, message): def report_analytics_event(entity, event, data={}): message = None - logging.info("Reporting analytics event %s with data %s.", event, data) - - if not settings.ANALYTICS_WEBHOOK_URL: - return - if event.startswith("User/"): user = entity @@ -85,5 +80,11 @@ def report_analytics_event(entity, event, data={}): }, } + if message: + logging.info("Reporting analytics event %s as message %s.", event, message) + + if not settings.ANALYTICS_WEBHOOK_URL: + return + if message: send_event_to_webhook(settings.ANALYTICS_WEBHOOK_URL, message).schedule() diff --git a/training-portal/src/project/apps/workshops/views/session.py b/training-portal/src/project/apps/workshops/views/session.py index 8fec2993..922955bc 100644 --- a/training-portal/src/project/apps/workshops/views/session.py +++ b/training-portal/src/project/apps/workshops/views/session.py @@ -199,6 +199,7 @@ def session_terminate(request, name): @login_required(login_url="/") @require_http_methods(["GET"]) @resources_lock +@transaction.atomic def session_delete(request, name): """Triggers deletion of a workshop session.""" diff --git a/training-portal/src/project/settings.py b/training-portal/src/project/settings.py index 44d425b1..f6776985 100644 --- a/training-portal/src/project/settings.py +++ b/training-portal/src/project/settings.py @@ -79,6 +79,9 @@ "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": os.path.join(DATA_DIR, "db.sqlite3"), + "OPTIONS": { + "timeout": 15, + } } }