Skip to content

Commit 2f4bbee

Browse files
authored
Polish qdp (o19s#1681)
* look up by the qdp id now supported * complete placeholder message for qdp id * show in hidden html the details.
1 parent 71264a6 commit 2f4bbee

4 files changed

Lines changed: 46 additions & 34 deletions

File tree

app/controllers/query_doc_pairs_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def index
1212
query = @book.query_doc_pairs
1313

1414
if params[:q].present?
15-
query = query.where('query_text LIKE ? OR doc_id LIKE ? OR document_fields LIKE ?',
16-
"%#{params[:q]}%", "%#{params[:q]}%", "%#{params[:q]}%")
15+
query = query.where('query_text LIKE ? OR query_doc_pairs.id LIKE ? OR doc_id LIKE ? OR document_fields LIKE ?',
16+
"%#{params[:q]}%", "%#{params[:q]}%", "%#{params[:q]}%", "%#{params[:q]}%")
1717
end
1818

1919
# Eager load judgements count to avoid N+1 queries when showing the count

app/views/judgements/_form.html.erb

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<% content_for :debug_info do %>
2+
<!--
3+
BOOK_ID: <%= @book.id %>
4+
QUERY_DOC_PAIR_ID: <%= query_doc_pair.id %>
5+
JUDGEMENT_ID: <%= judgement.id %>
6+
JUDGEMENT USER ID: <%= judgement&.user_id %>
7+
CURRENT USER ID: <%= @current_user.id %>
8+
-->
9+
<% end %>
110

211
<script>
312
function rate(rating, key_name) {
@@ -12,12 +21,12 @@
1221
keyboard_shortcuts_suffixes.forEach(suffix => {
1322
const spanElement = document.getElementById("span-for-" + suffix);
1423
const buttonElement = document.getElementById("button-for-" + suffix);
15-
24+
1625
if (spanElement) {
1726
spanElement.style.color = "gray";
1827
spanElement.style.fontWeight = "normal";
1928
}
20-
29+
2130
if (buttonElement) {
2231
buttonElement.classList.remove("btn-preselected");
2332
}
@@ -30,12 +39,12 @@
3039
if (suffix !== except_suffix) {
3140
const spanElement = document.getElementById("span-for-" + suffix);
3241
const buttonElement = document.getElementById("button-for-" + suffix);
33-
42+
3443
if (spanElement) {
3544
spanElement.style.color = "gray";
3645
spanElement.style.fontWeight = "normal";
3746
}
38-
47+
3948
if (buttonElement) {
4049
buttonElement.classList.remove("btn-preselected");
4150
}
@@ -47,12 +56,12 @@
4756
resetStyles();
4857
const spanElement = document.getElementById("span-for-" + suffix);
4958
const buttonElement = document.getElementById("button-for-" + suffix);
50-
59+
5160
if (spanElement) {
5261
spanElement.style.color = "black";
5362
spanElement.style.fontWeight = "bold";
5463
}
55-
64+
5665
if (buttonElement) {
5766
buttonElement.classList.add("btn-preselected");
5867
}
@@ -91,7 +100,7 @@
91100
}
92101

93102
const keyCode = e.which || e.keyCode;
94-
103+
95104
if (keyCode == 97 || keyCode == 65) {
96105
keyPressed("a");
97106
} else if (keyCode == 115 || keyCode == 83) {
@@ -120,9 +129,9 @@
120129
if (isExplanationModalOpen() || isTypingInTextField()) {
121130
return;
122131
}
123-
132+
124133
const keyCode = e.which || e.keyCode;
125-
134+
126135
if (keyCode == 97 || keyCode == 65) {
127136
keyDown("a");
128137
} else if (keyCode == 115 || keyCode == 83) {
@@ -211,7 +220,7 @@
211220
</div>
212221

213222

214-
<div class="float-end">
223+
<div class="float-end">
215224
<%= link_to 'I will Judge Later', book_query_doc_pair_judge_later_path(@book, query_doc_pair), class: 'btn btn-info m-1', role: 'button' %>
216225
<br/>
217226
<button type="button" class="btn btn-warning m-1" data-bs-toggle="modal" data-bs-target="#explanationModal">
@@ -222,12 +231,12 @@
222231
<p class="card-text">
223232
<%= render 'query_doc_pairs/document_fields', document_fields: @document_fields %>
224233
</p>
225-
234+
226235
<div class="mt-3">
227236
<label for="judgement_explanation" class="form-label">Explanation (optional)</label>
228237
<%= form.text_area :explanation, class: 'form-control', rows: 2, placeholder: 'Why did you choose this rating?' %>
229238
</div>
230-
239+
231240
<% if @book.show_rank? %>
232241
<p class="card-text">
233242
<b>Document Rank: </b><%= judgement.query_doc_pair.position %>
@@ -275,7 +284,7 @@
275284
</tr>
276285
</table>
277286
<% end %>
278-
287+
279288

280289
</div>
281290
<% if image_url %>

app/views/layouts/application.html.erb

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
<!DOCTYPE html>
22
<html>
3+
<% if content_for?(:debug_info) %>
4+
<%= yield :debug_info %>
5+
<% end %>
36
<head>
47
<meta charset="utf-8"/>
58
<meta name="viewport" content="width=device-width,initial-scale=1">
69
<meta name="apple-mobile-web-app-capable" content="yes">
710
<meta name="mobile-web-app-capable" content="yes">
811
<%= action_cable_meta_tag %>
912
<base href="<%= ENV['RAILS_RELATIVE_URL_ROOT'] %>/">
10-
13+
1114
<%= favicon_link_tag asset_path "favicon.ico" %>
1215

1316

1417
<% if flash[:unfurl] %>
1518
<!-- We have unfurl -->
16-
19+
1720
<title>Quepid: Case <%= flash[:unfurl]["case_name"] %></title>
18-
21+
1922
<!-— facebook open graph tags -->
2023
<meta property="og:type" content="website" />
2124
<% if flash[:unfurl]["id"] %>
@@ -24,7 +27,7 @@
2427
<meta property="og:title" content="Case <%= flash[:unfurl]["case_name"] %>" />
2528
<meta property="og:description" content="Case <%= flash[:unfurl]["case_name"] %> Description here." />
2629
<meta property="og:image" content="<%= image_url "quepid-icon.png" %>" />
27-
30+
2831
<!-— twitter card tags additive with the og: tags -->
2932
<meta name="twitter:card" content="summary">
3033
<meta name="twitter:site" content="@quepid_search">
@@ -38,17 +41,17 @@
3841
<meta name="twitter:data1" value="<%=Case.find_by_id(flash[:unfurl]["id"]).tries.latest.try_number %>" />
3942
<% end %>
4043
<% else %>
41-
44+
4245
<title>Quepid -- Relevant Search Solved</title>
43-
46+
4447
<!-— facebook open graph tags -->
4548
<meta property="og:type" content="website" />
4649
<meta name="twitter:site" content="@quepid_search">
4750
<meta property="og:url" content="<%= root_path %>" />
4851
<meta property="og:title" content="Quepid -- Relevant Search Solved" />
4952
<meta property="og:description" content="Tired of irrelevant search results? Use Quepid products & services to help improve the quality and relevancy of your search results." />
5053
<meta property="og:image" content="<%= image_url "quepid-icon.png" %>" />
51-
54+
5255
<!-— twitter card tags additive with the og: tags -->
5356
<meta name="twitter:card" content="summary">
5457
<meta name="twitter:domain" value="<%= URI.parse(root_url).host %>" />
@@ -65,7 +68,7 @@
6568

6669
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbo-track': 'reload' %>
6770
<%= csrf_meta_tags %>
68-
71+
6972
<%= javascript_importmap_tags 'application_modern' %>
7073
<%= debugbar_head if defined? Debugbar %>
7174

@@ -77,17 +80,17 @@
7780

7881
<div class="container-fluid">
7982
<div class="row">
80-
83+
8184
<% if @current_user && !(controller_name == 'judgements' and ['new','edit'].any? params[:action]) %>
8285
<%= render 'layouts/sidebar' %>
8386
<% end %>
84-
87+
8588
<!-- Begin page content -->
8689
<main class="col-md-10 ms-sm-auto col-lg-<%= @current_user ? '11' : '12' %> px-md-5">
8790
<%= yield %>
8891
</main>
8992
</div>
9093
</div>
91-
<%= debugbar_body if defined? Debugbar %>
94+
<%= debugbar_body if defined? Debugbar %>
9295
</body>
9396
</html>

app/views/query_doc_pairs/index.html.erb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="btn-toolbar mb-2 mb-md-0">
44
<div class="btn-group me-2">
55
<%= link_to 'New Query Doc Pair', new_book_query_doc_pair_path, class: 'btn btn-sm btn-outline-secondary' %>
6-
<%= link_to "Back to Book", @book, class: 'btn btn-sm btn-outline-secondary' %>
6+
<%= link_to "Back to Book", @book, class: 'btn btn-sm btn-outline-secondary' %>
77
</div>
88
</div>
99
</div>
@@ -18,7 +18,7 @@
1818
<div class="input-group" style="max-width: 400px;">
1919
<%= text_field_tag :q, params[:q],
2020
class: 'form-control form-control-sm',
21-
placeholder: 'Filter by query, doc id, or document field contents',
21+
placeholder: 'Filter by id, query, doc id, or document field contents',
2222
id: 'q'
2323
%>
2424
<%= button_tag type: 'submit', class: 'btn btn-sm btn-outline-secondary', id: 'button-addon2' do %>
@@ -40,7 +40,7 @@
4040
</div>
4141
<% end %>
4242
</div>
43-
43+
4444
<div class="card-body">
4545
<table class="table table-hover table-sm">
4646
<thead>
@@ -55,22 +55,22 @@
5555
<th>Document fields</th>
5656
</tr>
5757
</thead>
58-
59-
<tbody>
58+
59+
<tbody>
6060
<% @query_doc_pairs.each do |query_doc_pair| %>
6161
<tr>
6262
<td>
6363
<%= link_to query_doc_pair.id, book_query_doc_pair_path(@book, query_doc_pair) %>
6464
</td>
65-
65+
6666
<td><%= query_doc_pair.query_text %></td>
6767
<td><%= query_doc_pair.position %></td>
6868
<td><%= query_doc_pair.doc_id %></td>
6969
<% if @include_judgement_count %>
7070
<td>
7171
<%= link_to_if query_doc_pair.judgements_count>0, query_doc_pair.judgements_count, book_judgements_path(@book, q: "query_doc_pair_id:#{query_doc_pair.id}") %>
7272
</td>
73-
<% end %>
73+
<% end %>
7474
<td>
7575
<% if query_doc_pair.document_fields.present? %>
7676
<% document_fields_json = query_doc_pair.document_fields.to_json %>
@@ -92,7 +92,7 @@
9292
</table>
9393
</div>
9494
<div class="card-footer d-flex justify-content-center">
95-
<%== @pagy.series_nav(:bootstrap) %>
95+
<%== @pagy.series_nav(:bootstrap) %>
9696
</div>
9797

9898
<!-- Document Fields Modal -->

0 commit comments

Comments
 (0)