Skip to content

Commit

Permalink
Add section on indexing process
Browse files Browse the repository at this point in the history
Closes #2328
  • Loading branch information
maxkadel committed Oct 23, 2024
1 parent 6d327f9 commit 7a70b76
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
<div class="container">
<%= render partial: "shared/navbar" %>
<%= render partial: "shared/flash_messages", flash: flash %>
<%= yield %>
<main>
<%= yield %>
</main>
</div>
<div class="deployment-version">
<div class="deployment-version" role="contentinfo">
Version <span title="<%= GIT_SHA %>"><%= BRANCH %> last updated <%= LAST_DEPLOYED %>.</span>
</div>
</body>
Expand Down
21 changes: 21 additions & 0 deletions app/views/pages/index.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
<h1>PUL Bibliographic Data Web Service</h1>
<h2>Indexing Process</h2>
<table class="table table-condensed">
<thead>
<tr>
<th>Solr collection</th>
<th>Last dump indexed</th>
<th>Timestamp</th>
<th>In progress</th>
</tr>
</thead>
<tbody>
<% IndexManager.all.each do |index_manager| %>
<tr>
<td><%= index_manager.solr_collection %></td>
<td><%= index_manager.last_dump_completed_id ? link_to(index_manager.last_dump_completed_id, dump_url(index_manager.last_dump_completed_id, format: :json)) : '' %></td>
<td><%= index_manager.updated_at %></td>
<td><%= index_manager.in_progress %></td>
</tr>
<% end %>
</tbody>
</table>
29 changes: 29 additions & 0 deletions spec/views/pages/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true
require "rails_helper"

RSpec.describe "pages/index", type: :view do
it 'renders the header' do
render
expect(rendered).to match(/<h1>PUL Bibliographic Data Web Service<\/h1>/)
end
it 'includes a section on the indexing process' do
render
expect(rendered).to match(/<h2>Indexing Process<\/h2>/)
expect(rendered).to match(/<th>Last dump indexed<\/th>/)
expect(rendered).to match(/<th>Timestamp<\/th>/)
expect(rendered).to match(/<th>In progress<\/th>/)
end
context 'with index managers' do
let!(:index_manager1) { FactoryBot.create(:index_manager, solr_collection: 'daily_indexing', last_dump_completed: FactoryBot.create(:incremental_dump)) }
let!(:index_manager2) { FactoryBot.create(:index_manager, solr_collection: 'rebuild_indexing', last_dump_completed: FactoryBot.create(:full_dump)) }

it 'includes the id of the last dump indexed' do
render

expect(rendered).to match(/#{index_manager1.last_dump_completed_id}/)
expect(rendered).to match(/#{index_manager2.last_dump_completed_id}/)
expect(rendered).to match(index_manager1.solr_collection)
expect(rendered).to have_link(index_manager1.last_dump_completed_id.to_s, href: "http://test.host/dumps/#{index_manager1.last_dump_completed_id}.json")
end
end
end

0 comments on commit 7a70b76

Please sign in to comment.