From 3b879015627d35411b9163666970a4ebb0ac0e27 Mon Sep 17 00:00:00 2001
From: Eric Pugh Export Case: {{ ctrl.theCase.ca
Detailed export is only supported from the individual Case view.
Team Name,Case Name,Case ID,Query Text,Doc ID,Title,Rating,Field1,...,FieldN
where Field1,...,FieldN
are specified under Settings in the Displayed Fields field.
+ CSV file with Team Name,Case Name,Case ID,Query Text,Doc ID,Position,Title,Rating,Field1,...,FieldN
where Field1,...,FieldN
are specified under Settings in the Displayed Fields field.
diff --git a/app/assets/javascripts/services/caseCSVSvc.js b/app/assets/javascripts/services/caseCSVSvc.js
index 871281b29..23f16e74e 100644
--- a/app/assets/javascripts/services/caseCSVSvc.js
+++ b/app/assets/javascripts/services/caseCSVSvc.js
@@ -79,6 +79,7 @@
'Case ID',
'Query Text',
'Doc ID',
+ 'Doc Position',
'Title',
'Rating',
];
@@ -353,7 +354,7 @@
csvContent += dataString + EOL;
}
else {
- angular.forEach(docs, function (doc) {
+ angular.forEach(docs, function (doc, index) {
var dataString;
var infoArray = [];
@@ -362,6 +363,7 @@
infoArray.push(stringifyField(aCase.lastScore.case_id));
infoArray.push(stringifyField(query.queryText));
infoArray.push(stringifyField(doc.id));
+ infoArray.push(stringifyField(index+1));
infoArray.push(stringifyField(doc.title));
infoArray.push(stringifyField(doc.getRating()));
From 1a834ff15f4371e4a225c41fc80007e0ba7630e9 Mon Sep 17 00:00:00 2001
From: Eric Pugh This tool is for testing out websocket handling in Quepid.
++ After clicking the button you should see a count down counter that updates every second in a alert box. +
From 9765a8f4ab54d0528d78bf3172549976b24210ab Mon Sep 17 00:00:00 2001 From: Eric Pugh<%=query.query_text%>
+ <% end %>
+ <% if counter > 0 %>
+ <%= query_count - counter %>
.
+ + This tool is for testing out background query running in Quepid. +
++ After clicking the button you should see a set of updates in a alert box. +
+ + + + + +<%= form_with(url: run_queries_admin_query_runner_index_path, local: true) do |form| %> +<%=query.query_text%>
+ <% end %>
+ <% if counter > 0 %>
+ <%= query_count - counter %>
.
+
+
+
<% if @case.scores.empty? %>
no scores yet
<% else %>
diff --git a/db/migrate/20240709141551_add_response_fields_to_snapshot_queries.rb b/db/migrate/20240709141551_add_response_fields_to_snapshot_queries.rb
new file mode 100644
index 000000000..ee1230529
--- /dev/null
+++ b/db/migrate/20240709141551_add_response_fields_to_snapshot_queries.rb
@@ -0,0 +1,6 @@
+class AddResponseFieldsToSnapshotQueries < ActiveRecord::Migration[7.1]
+ def change
+ add_column :snapshot_queries, :response_status, :integer
+ add_column :snapshot_queries, :response_body, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 116dc63f7..7f70c1063 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2024_06_26_181338) do
+ActiveRecord::Schema[7.1].define(version: 2024_07_09_141551) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -256,6 +256,8 @@
t.float "score"
t.boolean "all_rated"
t.integer "number_of_results"
+ t.integer "response_status"
+ t.text "response_body"
t.index ["query_id"], name: "query_id"
t.index ["snapshot_id"], name: "snapshot_id"
end
diff --git a/test/fixtures/queries.yml b/test/fixtures/queries.yml
index 9450a670f..b232733e9 100644
--- a/test/fixtures/queries.yml
+++ b/test/fixtures/queries.yml
@@ -51,6 +51,11 @@ fourth_query:
case: :queries_case
query_text: Fourth Query
arranged_at: 4
+
+blowup_query:
+ case: :queries_case
+ query_text: BLOWUP_QUERY
+ arranged_at: 5
a_query:
case: :snapshot_case
diff --git a/test/fixtures/snapshot_queries.yml b/test/fixtures/snapshot_queries.yml
index 5a6f36c4c..f72f23f34 100644
--- a/test/fixtures/snapshot_queries.yml
+++ b/test/fixtures/snapshot_queries.yml
@@ -5,6 +5,8 @@
# id :integer not null, primary key
# all_rated :boolean
# number_of_results :integer
+# response_body :text(65535)
+# response_status :integer
# score :float(24)
# query_id :integer
# snapshot_id :integer
diff --git a/test/lib/solr_arg_parser_test.rb b/test/lib/solr_arg_parser_test.rb
index 6bca66261..5a9ecb687 100644
--- a/test/lib/solr_arg_parser_test.rb
+++ b/test/lib/solr_arg_parser_test.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-o # frozen_string_literal: true
-
require 'test_helper'
class SolrArgParserTest < ActiveSupport::TestCase
diff --git a/test/services/fetch_service_test.rb b/test/services/fetch_service_test.rb
index 20a87903b..f75d7b140 100644
--- a/test/services/fetch_service_test.rb
+++ b/test/services/fetch_service_test.rb
@@ -18,7 +18,6 @@ class FetchServiceTest < ActiveSupport::TestCase
let(:options) do
{
debug_mode: true,
- fake_call: false,
snapshot_limit: 3,
}
end
@@ -29,27 +28,35 @@ class FetchServiceTest < ActiveSupport::TestCase
let(:es_try_with_curator_vars) { tries(:es_try_with_curator_vars) }
let(:try_with_headers) { tries(:try_with_headers) }
let(:first_query) { queries(:first_query) }
+ let(:blowup_query) { queries(:blowup_query) }
it 'creates a GET request' do
fetch_service = FetchService.new options
- response = fetch_service.create_request(atry, first_query)
+ response = fetch_service.make_request(atry, first_query)
assert_not_nil response
assert 200 == response.status
end
it 'works with custom headers and JSONP' do
fetch_service = FetchService.new options
- response = fetch_service.create_request(try_with_headers, first_query)
+ response = fetch_service.make_request(try_with_headers, first_query)
assert_not_nil response
assert 200 == response.status
end
it 'creates a POST request' do
fetch_service = FetchService.new options
- response = fetch_service.create_request(es_try_with_curator_vars, first_query)
+ response = fetch_service.make_request(es_try_with_curator_vars, first_query)
assert_not_nil response
assert 200 == response.status
end
+
+ it 'handles a failed search request' do
+ fetch_service = FetchService.new options
+ response = fetch_service.make_request(atry, blowup_query)
+ assert_not_nil response
+ assert 404 == response.status
+ end
end
describe 'Running a fetch cycle produces a snapshot' do
@@ -75,9 +82,13 @@ class FetchServiceTest < ActiveSupport::TestCase
{ id: 'doc2', explain: '2' }
]
+ response_status = 200
+ response_body = ''
+
assert_difference 'first_query.snapshot_queries.count' do
- snapshot_query = fetch_service.store_query_results first_query, docs
+ snapshot_query = fetch_service.store_query_results first_query, docs, response_status, response_body
assert_equal docs.size, snapshot_query.snapshot_docs.size
+ assert_equal response_status, snapshot_query.response_status
end
end
@@ -102,27 +113,10 @@ class FetchServiceTest < ActiveSupport::TestCase
end
end
- test 'think should what we have' do
- FetchService.new options
- end
-
- test 'should be able to handle a get' do
- fetch_service = FetchService.new options
-
- # should url: be in params? Or seperate?
- params = {
- url: 'http://solr.quepid.com:8983/solr/statedecoded/select', fl: 'id,text', q: 'legal', rows: 10, start: 0
- }
-
- fetch_service.fetch params
- assert_response :success
- end
-
- test 'should track failure' do
- assert true
- end
-
- test 'should track successes' do
- assert true
+ describe 'parsing a response' do
+ it 'lets you create a resopnse' do
+ response = Faraday::Response.new(status: 200)
+ assert_equal 200, response.status
+ end
end
end
diff --git a/test/support/webmock.rb b/test/support/webmock.rb
index 39a4f780a..27682cfe0 100644
--- a/test/support/webmock.rb
+++ b/test/support/webmock.rb
@@ -237,6 +237,21 @@ def setup
}
)
.to_return(status: 200, body: mock_statedecoded_body, headers: {})
+
+ # Testing out fetch service using
+ # search_endpoint for_case_queries_case
+ # try es_try_with_curator_vars
+ # query blowup_query
+ stub_request(:get, 'http://test.com/solr/tmdb/select?q=BLOWUP_QUERY')
+ .with(
+ headers: {
+ 'Accept' => '*/*',
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
+ 'Content-Type' => 'application/json',
+ 'User-Agent' => 'Faraday v2.9.0',
+ }
+ )
+ .to_return(status: 404, body: '', headers: {})
end
# rubocop:enable Metrics/MethodLength
From a69b32b7ceee176c63a73728a1bd0bd3cc7d4d7b Mon Sep 17 00:00:00 2001
From: Eric Pugh