From 4acbb510209b70433c37005ebc8bccc078458d3b Mon Sep 17 00:00:00 2001
From: Simon Mayer <simon.mayer@onb.ac.at>
Date: Thu, 22 Sep 2022 12:18:00 +0200
Subject: [PATCH] Changes for correct notification display when downloading
 files and adding documents to datasets

---
 app/javascript/channels/notification_channel.js | 4 ++--
 app/workers/export_dataset_worker.rb            | 2 +-
 config/cable.yml                                | 4 +++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/app/javascript/channels/notification_channel.js b/app/javascript/channels/notification_channel.js
index 7d47346..c820626 100644
--- a/app/javascript/channels/notification_channel.js
+++ b/app/javascript/channels/notification_channel.js
@@ -19,7 +19,7 @@ consumer.subscriptions.create("NotificationChannel", {
                 $("#experiment_area").attr("data-refresh", (!$("#experiment_area").attr("data-refresh")))
                 break
             case "notify":
-                if(window.location.pathname == "/search") {
+                if(window.location.pathname.endsWith("/search")) {
                     const selected_dataset = $("#working_dataset_select").val()
                     $("#working_dataset_select").html(data.dataset_options)
                     $("#working_dataset_select").val(selected_dataset)
@@ -35,7 +35,7 @@ consumer.subscriptions.create("NotificationChannel", {
                 }
                 break
             case "completion_rate":
-                if(window.location.pathname == `/experiment/${data.experiment_id}`) {
+                if(window.location.pathname.endsWith(`/experiment/${data.experiment_id}`)) {
                     const progress_bar = $(`#tool_${data.tool_id}`).find(".completion-rate").find('.progress-bar')
                     progress_bar.attr("style", `width: ${data.completion}%;`)
                     progress_bar.attr("aria-valuenow", data.completion)
diff --git a/app/workers/export_dataset_worker.rb b/app/workers/export_dataset_worker.rb
index a0a760b..9ef8beb 100644
--- a/app/workers/export_dataset_worker.rb
+++ b/app/workers/export_dataset_worker.rb
@@ -73,7 +73,7 @@ class ExportDatasetWorker
         File.delete("/tmp/#{filename}") if filename
       end
     end
-    content = "<p>Your dataset is ready. <a target=\"_blank\" href=\"/send?filename=#{File.basename(file.path)}\">Click here</a> to download it.</p>"
+    content = "<p>Your dataset is ready. <a target=\"_blank\" href=\"/en/tool/newspapers-platform/send?filename=#{File.basename(file.path)}\">Click here</a> to download it.</p>"
     ActionCable.server.broadcast("notifications.#{user_id}", {
       type: "notify",
       html: ApplicationController.render(partial: "shared/notification", locals: { notif_title: dataset.title, notif_content: content }),
diff --git a/config/cable.yml b/config/cable.yml
index 5fc7ec8..07fb37b 100644
--- a/config/cable.yml
+++ b/config/cable.yml
@@ -1,5 +1,7 @@
 development:
-    adapter: async
+  adapter: redis
+  url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+  channel_prefix: newspapers_platform_production_dev
 
 test:
   adapter: test
-- 
GitLab