Skip to content

Commit

Permalink
Merge branch 'main' into spike_5000_queries_round_deux
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Dec 12, 2024
2 parents ec87950 + d62d520 commit de534a8
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{{ ctrl.thisCase.lastScore.score }}

<span ng-show="ctrl.thisCase.lastScore.all_rated === false" class='text-warning' title="Hop to it! There are unrated results!">
<i class="bi bi-balloon-fill"></i>
<i class="frog-icon">🐸</i>
</span>
</div>

Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/components/frog_report/_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h3 class="modal-title">The Frog Pond Report: <span class="modal-case">{{ ctrl.t
</div>
<div class="modal-body frog-pond">
<div class="frog-pond-content">
<p>The accuracy of the scores calculated by Quepid is directly impacted by the number of <i class="bi bi-balloon" aria-hidden="true"></i>'s you have. Pop the balloons
<p>The accuracy of the scores calculated by Quepid is directly impacted by the number of 🐸's you have. Chase the frogs into the pond
(i.e rate your documents) so that you can have confidence in the changes you are making!</p>

<h4>Summary</h4>
Expand All @@ -18,7 +18,7 @@ <h4>Summary</h4>
</ng-pluralize>
<strong>zero</strong> results.

You need to maintain a total of {{ totalNumberOfRatingsNeeded }} ratings to eliminate all the balloons.<br/>
You need to maintain a total of {{ totalNumberOfRatingsNeeded }} ratings to eliminate all the 🐸.<br/>
<span ng-if="ctrl.theCase.lastScore.all_rated">
All the queries have been fully rated! Congratulations!
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<i class="bi bi-balloon-fill" aria-hidden="true"></i>
<i class="frog-icon" aria-hidden="true">🐸</i>
<a ng-click="ctrl.prompt()">
Report
</a>
15 changes: 12 additions & 3 deletions app/assets/stylesheets/animation.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ using ngAnimate and css from the https://animate.style project



/* being alert icon for missing ratings */
/* begin alert icon for missing ratings */
.icon-container {
position: relative;
display: inline-block;
Expand All @@ -91,12 +91,21 @@ using ngAnimate and css from the https://animate.style project
position: absolute;
top: -10px; /* Adjust as needed */
right: -12px; /* Adjust as needed */
background-color: rgba(255, 0, 0, 0.5); /* Red with 50% opacity */
background-color: rgba(255, 0, 0, 0.7); /* Red with 50% opacity */
color: white;
border-radius: 50%;
padding: 5px 8px;
width: 20px; /* Set width */
height: 20px; /* Set height equal to width */
display: flex; /* Center content */
justify-content: center; /* Center content horizontally */
align-items: center; /* Center content vertically */
font-size: 12px;
}

.frog-icon {
color: grey;
filter: grayscale(100%);
}
/* end alert icon for missing ratings */

.spinner {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/froggy.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
display: inline-block;
width: 24px; /* Adjust to match your image width */
height: 24px; /* Adjust to match your image height */
background-image: url('querqy-icon.png');
background-image: url('images/querqy-icon.png');
background-size: contain;
background-repeat: no-repeat;
background-position: center;
Expand Down
4 changes: 2 additions & 2 deletions app/assets/templates/views/searchResults.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ <h2 class="results-title">

<span ng-show="query.isNotAllRated()" class="pull-right" style="margin-right: 20px;" title="Hop to it! There are unrated results!">
<div class="icon-container">
🐸
<div class="notification-bubble">3</div>
<i class="frog-icon">🐸</i>
<div class="notification-bubble">{{ query.currentScore.countMissingRatings }}</div>
</div>
</span>

Expand Down
41 changes: 40 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# frozen_string_literal: true

# rubocop:disable Metrics/ModuleLength
module ApplicationHelper
def book_title book
if book.name.downcase.starts_with?('book')
book.name
book.name.capitalize
else
"Book #{book.name}"
end
end

def case_title kase
if kase.case_name.downcase.starts_with?('case')
kase.case_name.capitalize
else
"Case #{kase.case_name}"
end
end

def display_judge_name judge
judge.nil? ? 'anonymous' : judge.fullname
end
Expand Down Expand Up @@ -99,4 +108,34 @@ def form_with_disabled(model: nil, **options, &block)
# Call the original `form_with` method with the modified options
super
end

# Match the link to the core case url with the endpoint_url
# if we have one. Avoids a swap in the core application.
def link_to_core_case name, kase, try_number, options = {}
# Ensure options[:data] is set to { turbo_prefetch: false }
options[:data] ||= {}
options[:data][:turbo_prefetch] = false

endpoint_url = kase.tries.first&.search_endpoint&.endpoint_url
protocol = nil
if endpoint_url
protocol = get_protocol_from_url(endpoint_url)
port = 443 if 'https' == protocol
end
path = case_core_url(kase, try_number, protocol: protocol, port: port)

# Call the original link_to method with the modified options
link_to(name, path, options)
end

def get_protocol_from_url url
parsed_url = URI.parse(url)
protocol = parsed_url.scheme # This gets the protocol (http, https, etc.)
protocol
rescue URI::InvalidURIError => e
# Handle the error (e.g., log it, return nil)
Rails.logger.error("Invalid URL for search endpoint: #{url} - Error: #{e.message}")
nil
end
end
# rubocop:enable Metrics/ModuleLength
8 changes: 2 additions & 6 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ def greeting2
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength

def case_title kase
if kase.case_name.downcase.starts_with?('case')
kase.case_name
else
"Case #{kase.case_name}"
end
def strip_case_title kase
kase.case_name.sub(/^case\s+/i, '').capitalize
end
end
2 changes: 1 addition & 1 deletion app/views/analytics/tries_visualization/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= link_to 'Return to Case', case_core_path(@case) %>
<%= link_to_core_case 'Return to Case', @case, @case.last_try_number %>

<div id="tries_tree_view"></div>
<script type="text/javascript">
Expand Down
2 changes: 1 addition & 1 deletion app/views/books/_case.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= link_to kase.case_name, case_core_path(kase.id, kase.last_try_number) %>
<%= link_to_core_case case_title(kase), kase, kase.last_try_number %>
2 changes: 1 addition & 1 deletion app/views/home/_book_summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</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="bi bi-balloon"></i> You need to judge <%= @lookup_for_books[book] %> out <%= book.query_doc_pairs.count %> query/doc pairs.</p>
<p class="card-text text-danger"><i class="frog-icon" aria-hidden="true">🐸</i> You need to judge <%= @lookup_for_books[book] %> out <%= book.query_doc_pairs.count %> query/doc pairs.</p>
<% end %>
<%= link_to 'Judge', book_judge_path(book), data: { turbo_prefetch: false }, class: 'btn btn-sm btn-primary', role: 'button' %>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/views/home/_case.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<tr>
<th scope="row"><%= kase.id %></th>
<th scope="row"><%= kase.case_name %></th>
<th scope="row"><%= strip_case_title(kase) %></th>
<td><%= kase.queries_count %></td>
<td>
<% unless kase.last_score.blank? %>
Expand All @@ -17,6 +17,6 @@
<%= kase.last_score.user.name %>
<% end %>
</td>

<td><%= link_to 'View', case_core_path(kase, kase.last_try_number), data: { turbo_prefetch: false }, class: 'btn btn-sm btn-primary', role: 'button' %></td>
<td><%= link_to_core_case 'View', kase, kase.last_try_number, class: 'btn btn-sm btn-primary', role: 'button' %>
</td>
</tr>
2 changes: 1 addition & 1 deletion app/views/home/_case_summary.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="col-12 col-md-6 mb-4 mb-lg-0 col-lg-3">
<div class="card h-100">
<h5 class="card-header text-truncate">
<%= link_to case_title(kase), case_core_path(kase, kase.last_try_number), data: { turbo_prefetch: false } %>
<%= link_to_core_case case_title(kase), kase, kase.last_try_number %>
</h5>

<div class="card-body">
Expand Down
2 changes: 1 addition & 1 deletion app/views/home/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Inspired by https://dev.to/themesberg/tutorial-how-to-build-a-simple-admin-dashb
</tbody>
</table>
</div>
<%= link_to 'View all cases', cases_path(), class: 'btn btn-block btn-light', role: 'button' %>
<%= link_to 'View all Cases', cases_path(), class: 'btn btn-block btn-light', role: 'button' %>

</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/judgements/_moar_judgements_needed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<% else %>
Return to the linked Case
<% book.cases.each do |kase| %>
<%= link_to kase.case_name, case_core_path(kase, kase.last_try_number), class: 'alert-link' %>
<%= link_to_core_case case_title(kase), kase, kase.last_try_number, class: 'alert-link' %>
<% end %>
and using the <b><i class="bi bi-book-half"></i> Judgements</b> to populate this Book with query/doc pairs for judging.
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</li>
<li><hr class="dropdown-divider"></li>
<% set_recent_cases.each do |kase| %>
<li><%= link_to kase.case_name, case_core_path(kase, kase.last_try_number) %></li>
<li><%= link_to_core_case kase.case_name, kase, kase.last_try_number %></li>
<li><hr class="dropdown-divider"></li>
<% end %>

Expand Down
4 changes: 2 additions & 2 deletions app/views/ratings/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<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">Ratings for Case <%= @case.case_name %></h1>
<h1 class="h2">Ratings for <%= case_title(@case) %></h1>
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group me-2">
<%= link_to "Back to Case #{@case.case_name}", case_core_path(@case), class: "btn btn-sm btn-outline-secondary" %>
<%= link_to_core_case "Back to #{case_title(@case)}", @case, @case.last_try_number, class: 'btn btn-sm btn-outline-secondary' %>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search_endpoints/_case.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= link_to kase.case_name, case_core_path(kase.id) %>
<%= link_to_core_case kase.case_name, kase, kase.last_try_number %>
26 changes: 26 additions & 0 deletions test/helpers/application_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,30 @@ class ApplicationHelperTest < ActionView::TestCase
safe_list_sanitizer.sanitize("Bold</b> no more! <a href='more.html'>See more here</a>...")
assert_equal '<b>Bold</b><i>Trailing italics</i>', safe_list_sanitizer.sanitize('<b>Bold</b><i>Trailing italics')
end

let(:random_case) { cases(:random_case) }
def test_link_to_core_case
try_number = 2
expected_link_text = 'View Case'
expected_path = case_core_url(random_case, try_number)

# Call the helper method
result = link_to_core_case(expected_link_text, random_case, try_number)

# Assertions
assert_includes result, expected_link_text
assert_includes result, expected_path
assert_includes result, "href=\"#{expected_path}\""
end

def test_link_to_core_case_with_options
try_number = 2
options = { class: 'btn btn-primary' }

# Call the helper method
result = link_to_core_case('View Case', random_case, try_number, options)

# Assertions for the options
assert_includes result, 'class="btn btn-primary"'
end
end

0 comments on commit de534a8

Please sign in to comment.