Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Apr 15, 2024
1 parent 7bab189 commit 84b8e75
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 24 deletions.
7 changes: 4 additions & 3 deletions app/jobs/export_book_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def perform book
:notifications,
target: 'notifications',
partial: 'books/notification',
locals: { message: "Starting to export book #{book.name}" }
locals: { book: book, message: "Starting to export book #{book.name}" }
)

json_data = Api::V1::Export::BooksController.renderer.render template: 'api/v1/export/books/show',
Expand All @@ -24,7 +24,7 @@ def perform book
:notifications,
target: 'notifications',
partial: 'books/notification',
locals: { message: "JSON exported for #{book.name}, starting to create file" }
locals: { book: book, message: "JSON exported for #{book.name}, starting to create file" }
)

book.export_file.attach(io: compressed_data, filename: "book_export_#{book.id}.json.zip",
Expand All @@ -34,7 +34,8 @@ def perform book
:notifications,
target: 'notifications',
partial: 'books/notification',
locals: { message: "Completed exporting book #{book.name}. Please refresh the page to get the link." }
locals: { book: book,
message: "Completed exporting book #{book.name}. Please refresh the page to get the link." }
)
end
# rubocop:enable Metrics/MethodLength
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/populate_book_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def perform user, book, kase
:notifications,
target: 'notifications',
partial: 'books/blah',
locals: { counter: counter, qdp: query_doc_pair }
locals: { book: book, counter: counter, qdp: query_doc_pair }
)
end
book.populate_file.purge
Expand Down
2 changes: 1 addition & 1 deletion app/services/book_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def import
:notifications,
target: 'notifications',
partial: 'books/blah',
locals: { counter: counter, qdp: qdp }
locals: { book: @book, counter: counter, qdp: qdp }
)
next unless query_doc_pair[:judgements]

Expand Down
2 changes: 1 addition & 1 deletion app/views/books/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div class="mb-3">
<div class="form-check form-switch">
<%= form.label :link_the_case, class:'form-check-label' %>
<%= form.check_box :link_the_case, class:'form-check-input' %>
<%= form.check_box :link_the_case, class:'form-check-input', checked: true %>
<%= @origin_case.case_name %> to this book?
</div>
<%= form.hidden_field :origin_case_id, :value => @origin_case.id %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/books/_notification.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= turbo_stream.replace "book-import-notifications" do %>
<span id="book-import-notifications">
<%= turbo_stream.replace "notification-book-#{book.id}" do %>
<span id="notification-book-<%= book.id %>">
<div class="alert alert-info" role="alert">
<%= message %>
</div>
Expand Down
4 changes: 4 additions & 0 deletions app/views/books/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= turbo_stream_from(:notifications) %>

<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Books</h1>
<div class="btn-toolbar mb-2 mb-md-0">
Expand Down Expand Up @@ -45,6 +47,8 @@
<td>
<span class="badge bg-primary rounded-pill"><%= book.query_doc_pairs.count %> query/doc pairs</span>
<span class="badge bg-primary rounded-pill"><%= book.rated_query_doc_pairs.count %> rated query/doc pairs</span>
<span id="notification-book-<%= book.id %>">
</span>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/books/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This book consists of <%= @book.query_doc_pairs.count %> query document pairs an

<%= render 'judgements/moar_judgements_needed', book: @book %>

<span id="book-import-notifications">
<span id="notification-book-<%= @book.id %>">
</span>

<% if @count_of_anonymous_book_judgements > 0 %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/home/_book_summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
</h5>
<p class="card-text"><%= book.judgements.count %> Judgements
</p>
<span id="notification-book-<%= book.id %>">
</span>
<!-- Look at https://github.com/ankane/prophet-ruby -->
<% if @lookup_for_books[book] && @lookup_for_books[book] > 0 %>
<p class="card-text text-danger"><i class="fa fa-frog"></i> You need to judge <%= @lookup_for_books[book] %> out <%= book.query_doc_pairs.count %> query/doc pairs.</p>
Expand Down
4 changes: 2 additions & 2 deletions app/views/home/_case_summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<h5 class="card-title"><%= number_with_precision(kase.last_score.score, precision: 2) unless kase.scores.empty? %> <%= kase.scorer.name %></h5>
<p class="card-text"><%= kase.created_at.to_date.to_fs(:short) %> - <%= kase.last_score.updated_at.to_date.to_fs(:short) unless kase.scores.empty?%>
</p>
<turbo-frame id="case_prophet_frame_<%= kase.id %>" src="<%= home_case_prophet_url(kase) %>">
<turbo-frame id="case_prophet_frame_<%= kase.id %>" src="<%= home_case_prophet_path(kase) %>">
<p class="card-text placeholder-glow">
<span class="placeholder col-11"></span>
<span class="placeholder col-11"></span>
</p>
<%= Vega.lite
.mark(type: "line", tooltip: true, interpolate: "cardinal", point: {size: 60})
Expand Down
3 changes: 2 additions & 1 deletion app/views/home/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!--
Inspired by https://dev.to/themesberg/tutorial-how-to-build-a-simple-admin-dashboard-interface-using-bootstrap-5-2734
-->
<%= turbo_stream_from(:notifications) %>

<div class="text-center">
<p/>
Expand Down Expand Up @@ -69,7 +70,7 @@ Inspired by https://dev.to/themesberg/tutorial-how-to-build-a-simple-admin-dashb
<% end %>
<hr/>
<turbo-frame id="sparklines_tray" src="<%= home_sparklines_url %>">
<turbo-frame id="sparklines_tray" src="<%= home_sparklines_path %>">
<div class="spinner-border" role="status">
<span class="visually-hidden">Loading...</span>
</div>
Expand Down
19 changes: 7 additions & 12 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# frozen_string_literal: true

# Redis and Sidekiq is used only for sending Google Analytics updates, which is
# primarily used by the app.quepid.com install. This checks if we need Sidekiq.
if Rails.application.config.google_analytics_enabled
sidekiq_config = { url: ENV.fetch('REDIS_URL'),
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } }

sidekiq_config = { url: ENV.fetch('REDIS_URL', nil),
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE } }

Sidekiq.configure_server do |config|
config.redis = sidekiq_config
end
Sidekiq.configure_server do |config|
config.redis = sidekiq_config
end

Sidekiq.configure_client do |config|
config.redis = sidekiq_config
end
Sidekiq.configure_client do |config|
config.redis = sidekiq_config
end

0 comments on commit 84b8e75

Please sign in to comment.