diff --git a/app/controllers/dataset_controller.rb b/app/controllers/dataset_controller.rb index 53601074b18330fbf89bdc166f0a21f4ab0089ec..e3d41a120097fdbf67390fe80a1305d2ea28fdf7 100644 --- a/app/controllers/dataset_controller.rb +++ b/app/controllers/dataset_controller.rb @@ -130,7 +130,7 @@ class DatasetController < ApplicationController message = "
#{@nb_added_docs} document#{@nb_added_docs > 1 ? "s were" : " was"} added to your dataset.
" message.concat "#{existing.size} document#{existing.size > 1 ? "s" : ""} already exist in this dataset.
" unless existing.empty? # render partial: "shared/notification", locals: {notif_title: title, notif_content: message.html_safe} - out["notif"] = render_to_string layout: false, partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe } + out["notif"] = render_to_string layout: false, partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe, notif_autohide: "true" } out["nbissues"] = dataset.documents.select { |d| d["type"] == "issue" }.size out["nbarticles"] = dataset.documents.select { |d| d["type"] == "article" }.size out["nbdocs"] = out["nbissues"] + out["nbarticles"] @@ -145,7 +145,7 @@ class DatasetController < ApplicationController existing = dataset.add_compound params[:compound_id] # Add docs and return existing ids title = dataset.title message = "The compound article was added to your dataset.
" - out["notif"] = render_to_string layout: false, partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe } + out["notif"] = render_to_string layout: false, partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe, notif_autohide: "true" } out["nbissues"] = dataset.documents.select { |d| d["type"] == "issue" }.size out["nbarticles"] = dataset.documents.select { |d| d["type"] == "article" }.size out["nbcompounds"] = dataset.documents.select { |d| d["type"] == "compound" }.size @@ -164,21 +164,27 @@ class DatasetController < ApplicationController end def add_all_documents - SearchToDatasetWorker.perform_async(current_user.id, session[:working_dataset], params[:search_params].to_unsafe_h) + time = Time.now.to_i + SearchToDatasetWorker.perform_async(current_user.id, session[:working_dataset], params[:search_params].to_unsafe_h, time) title = Dataset.find(session[:working_dataset]).title message = "Documents are being added to your dataset.
The export is being prepared. You will be notified when the operation is done.
" - render partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe } + message = "The export is being prepared.
Your dataset is ready. Click here to download it.
" ActionCable.server.broadcast("notifications.#{user_id}", { type: "notify", - html: ApplicationController.render(partial: "shared/notification", locals: { notif_title: dataset.title, notif_content: content }), + html: ApplicationController.render(partial: "shared/notification", locals: { notif_title: dataset.title, notif_content: content, notif_autohide: "false" }), }) end diff --git a/app/workers/search_to_dataset_worker.rb b/app/workers/search_to_dataset_worker.rb index f1126cf4f2d99b4fa82f5ca7174fb4d3979a89d6..cc1bc1a2afe3894b575ad8ada516da1432e1ce31 100644 --- a/app/workers/search_to_dataset_worker.rb +++ b/app/workers/search_to_dataset_worker.rb @@ -2,7 +2,7 @@ class SearchToDatasetWorker include Sidekiq::Worker include ActionView::Helpers::FormOptionsHelper - def perform(user_id, dataset_id, search_params) + def perform(user_id, dataset_id, search_params, time) puts "### #{search_params}" dataset = Dataset.find(dataset_id) search_params["fl"] = "id" @@ -22,6 +22,7 @@ class SearchToDatasetWorker ActionCable.server.broadcast("notifications.#{user_id}", { type: "completion_rate", dataset_id: dataset_id, + time: time, completion: completion, }) end @@ -33,7 +34,7 @@ class SearchToDatasetWorker dataset_options = options_for_select(User.find(user_id).datasets.map { |d| ["#{d.title} (#{d.documents.size} docs)", d.id] }) ActionCable.server.broadcast("notifications.#{user_id}", { type: "notify", - html: ApplicationController.render(partial: "shared/notification", locals: { notif_title: dataset.title, notif_content: content }), + html: ApplicationController.render(partial: "shared/notification", locals: { notif_title: dataset.title, notif_content: content, notif_autohide: "true" }), dataset_options: dataset_options, }) end