Skip to content
Snippets Groups Projects
Commit 897c50a0 authored by smayer's avatar smayer
Browse files

Add completion display for search_to_dataset_worker and proper Sidekiq client configuration

parent e12e3222
No related branches found
No related tags found
1 merge request!2Merging development into onb as preparation for Annolyzer release
...@@ -166,7 +166,11 @@ class DatasetController < ApplicationController ...@@ -166,7 +166,11 @@ class DatasetController < ApplicationController
def add_all_documents def add_all_documents
SearchToDatasetWorker.perform_async(current_user.id, session[:working_dataset], params[:search_params].to_unsafe_h) SearchToDatasetWorker.perform_async(current_user.id, session[:working_dataset], params[:search_params].to_unsafe_h)
title = Dataset.find(session[:working_dataset]).title title = Dataset.find(session[:working_dataset]).title
message = "<p>Documents are being added to your dataset. You will be notified when the operation is done.</p>" message = "<p>Documents are being added to your dataset.</p><div class=\"completion-rate mt-2\">
<div class=\"progress\" id=\"progress-#{session[:working_dataset]}\">
<div class=\"progress-bar progress-bar-striped\" role=\"progressbar\" style=\"width: 0%;\" aria-valuenow=\"0\" aria-valuemin=\"0\" aria-valuemax=\"100\">0%</div>
</div>
</div>"
render partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe } render partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe }
end end
......
...@@ -41,6 +41,12 @@ consumer.subscriptions.create("NotificationChannel", { ...@@ -41,6 +41,12 @@ consumer.subscriptions.create("NotificationChannel", {
progress_bar.attr("aria-valuenow", data.completion) progress_bar.attr("aria-valuenow", data.completion)
progress_bar.html(`${data.completion}%`) progress_bar.html(`${data.completion}%`)
} }
if(window.location.pathname.endsWith("/search")) {
const progress_bar = $("#progress-".concat(data.dataset_id)).find('.progress-bar')
progress_bar.attr("style", `width: ${data.completion}%;`)
progress_bar.attr("aria-valuenow", data.completion)
progress_bar.html(`${data.completion}%`)
}
break break
case "experiment_finished": case "experiment_finished":
// $("#experiment_status").html(data.message) // $("#experiment_status").html(data.message)
......
...@@ -18,6 +18,12 @@ class SearchToDatasetWorker ...@@ -18,6 +18,12 @@ class SearchToDatasetWorker
res = SolrSearcher.query search_params res = SolrSearcher.query search_params
numFound = res["response"]["numFound"] numFound = res["response"]["numFound"]
doc_ids.concat res["response"]["docs"].map { |d| d["id"] } doc_ids.concat res["response"]["docs"].map { |d| d["id"] }
completion = (100 * doc_ids.size / numFound).to_i
ActionCable.server.broadcast("notifications.#{user_id}", {
type: "completion_rate",
dataset_id: dataset_id,
completion: completion,
})
end end
existing = dataset.add_documents doc_ids existing = dataset.add_documents doc_ids
nb_docs_added = doc_ids.size - existing.size nb_docs_added = doc_ids.size - existing.size
......
redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
Sidekiq.configure_server do |config| Sidekiq.configure_server do |config|
config.redis = { config.redis = redis
url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") end
}
Sidekiq.configure_client do |config|
config.redis = redis
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment