Skip to content

Commit

Permalink
Bugfixs from testing. (#894)
Browse files Browse the repository at this point in the history
* Deal with some search endpoints do not support lookup By Id

* text clean up, bit better ux

* werid edgecase

* This should fix #847

* Check if there are whitespace in field names.

* rolling back on some changes.....
  • Loading branch information
epugh authored Nov 30, 2023
1 parent bf311fd commit 37c1f3f
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ GEM
faraday (>= 1, < 3)
faraday-net_http (3.0.2)
ffi (1.16.3)
font-awesome-sass (6.4.2)
font-awesome-sass (6.5.0)
sassc (~> 2.0)
gabba (1.0.1)
get_process_mem (0.2.7)
Expand Down
19 changes: 10 additions & 9 deletions app/assets/javascripts/components/judgements/_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@ <h3 class="modal-title">Judgements</h3>
Explicit Judgements created by humans are a good way to start measuring your search quality.
</p>
<p>
You populate the book with the data returned by the try to give your raters a set of query/doc pairs to judge.
Quepid organizes Judgements in a <b>Book</b> that consists of query and document pairs for human evaluation.
Checkmark the <b>Populate Book</b> option to update the book with new and changed queries and documents returned by the Case.
</p>

<div class="text-center" ng-show="ctrl.share.teams.length === 0 && !ctrl.share.loading">
<p>
Books of Judgements are meant to be shared with a team, so either create a new team or close this modal and use <i
class="fa fa-share"
aria-hidden="true"
title="Share Case"
alt="Share Case"
></i> Share Case first.
Judgements are meant to be shared with a team, so either create a new team or
<share-case
acase="ctrl.share.acase" ng-click="ctrl.cancel()"
></share-case> first.
</p>



<a class="btn btn-primary btn-lg" ng-click="ctrl.goToTeamsPage()">
<i class="fa fa-plus"></i>
Expand All @@ -43,7 +44,7 @@ <h3 class="modal-title">Judgements</h3>

<div class="text-center" ng-show="ctrl.share.teams.length > 0 && ctrl.share.books.length === 0 && !ctrl.share.loading">
<p>
You have no Books of Judgements created yet, so go ahead and create a new Book!
You have not created any Books of Judgements yet, so go ahead and create a new Book!
</p>

<a class="btn btn-primary btn-lg" href="books/new" target="_self">
Expand Down Expand Up @@ -116,7 +117,7 @@ <h3 class="modal-title">Judgements</h3>

<a class="btn btn-default pull-left" ng-click="ctrl.refreshRatingsFromBook()" ng-disabled="processingPrompt.inProgress || ctrl.populateBook || !ctrl.activeBookId || ctrl.share.acase.bookId !== ctrl.activeBookId" >
<i class="glyphicon glyphicon-refresh"></i>
Refresh ratings from book <i>{{ctrl.activeBookName}}
Refresh ratings from book <i>{{ctrl.activeBookName}}</i>
</a>

<button
Expand Down
73 changes: 43 additions & 30 deletions app/assets/javascripts/controllers/wizardModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,37 +727,37 @@ angular.module('QuepidApp')
};

function createSnapshot() {
$scope.staticContent.import.loading = true;
$scope.isStaticCollapsed = false;

angular.forEach($scope.staticContent.result, function(doc) {
if (!$scope.listOfStaticQueries.includes(doc['Query Text'])){
$scope.listOfStaticQueries.push(doc['Query Text']);
}
$scope.staticContent.import.loading = true;
$scope.isStaticCollapsed = false;

angular.forEach($scope.staticContent.result, function(doc) {
if (!$scope.listOfStaticQueries.includes(doc['Query Text'])){
$scope.listOfStaticQueries.push(doc['Query Text']);
}
});

querySnapshotSvc.importSnapshotsToSpecificCase($scope.staticContent.result, caseTryNavSvc.getCaseNo())
.then(function () {
const keys = Object.keys(querySnapshotSvc.snapshots);
const snapshotId = keys[keys.length - 1];

console.log($location.absUrl) ;
$scope.pendingWizardSettings.searchUrl = `${$location.protocol()}://${$location.host()}:${$location.port()}/api/cases/${caseTryNavSvc.getCaseNo()}/snapshots/${snapshotId}/search`;
$scope.isStaticCollapsed = false;
$scope.addedStaticQueries = true;
//var result = {
// success: true,
// message: 'Static Data imported successfully!',
// };
$scope.staticContent.import.loading = false;
}, function () {
//var result = {
// error: true,
// message: 'Could not import static data successfully! Please try again.',
//};

$scope.staticContent.import.loading = false;
});

querySnapshotSvc.importSnapshotsToSpecificCase($scope.staticContent.result, caseTryNavSvc.getCaseNo())
.then(function () {
const keys = Object.keys(querySnapshotSvc.snapshots);
const snapshotId = keys[keys.length - 1];

console.log($location.absUrl) ;
$scope.pendingWizardSettings.searchUrl = `${$location.protocol()}://${$location.host()}:${$location.port()}/api/cases/${caseTryNavSvc.getCaseNo()}/snapshots/${snapshotId}/search`;
$scope.isStaticCollapsed = false;
$scope.addedStaticQueries = true;
//var result = {
// success: true,
// message: 'Static Data imported successfully!',
// };
$scope.staticContent.import.loading = false;
}, function () {
//var result = {
// error: true,
// message: 'Could not import static data successfully! Please try again.',
//};

$scope.staticContent.import.loading = false;
});
}
$scope.checkStaticHeaders = checkStaticHeaders;
function checkStaticHeaders () {
Expand All @@ -779,6 +779,19 @@ angular.module('QuepidApp')

$scope.staticContent.import.alert = alert;
}

const documentHeaders = headers.filter(item => !expectedHeaders.includes(item));
const containsSpace = documentHeaders.some(item => item.trim().includes(' '));
if (containsSpace) {
var alert = 'Document field names may not contain whitespace: ';
alert += '<br /><strong>';
alert += documentHeaders.join(',');
alert += '</strong>';

$scope.staticContent.import.alert = alert;
}


}

$scope.$watch('staticContent.content', function (newVal, oldVal) {
Expand Down
7 changes: 7 additions & 0 deletions app/assets/javascripts/services/bookSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ angular.module('QuepidApp')
fields[field['field']] = field['value'];
});
fields['title'] = doc.title;
// interesting issue, which is for a doc with attributes title and text, if the fieldspec is
// title:text, title, then we need special logic to actually GET the title attribute out and map it to title_field,
// because otherwise we just overwrite it.
if (doc.doc.title !== undefined && doc.doc.title !== doc.title){
fields['title_field'] = doc.doc.title;
}

if (doc.hasThumb()) {
fields['thumb'] = doc.thumb;
}
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/services/docCacheSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ angular.module('QuepidApp')

var docIds = Object.keys(docsToFetch);
var resolver = docResolverSvc.createResolver(docIds, settings, 15);

// 'vectara' does not support doc lookup by ID.
let supportLookupById = true;
if (settings && settings.searchEngine === 'vectara'){
Expand All @@ -72,7 +72,7 @@ angular.module('QuepidApp')
}


if ( supportLookupById && docIds.length > 0 ) {
if ( supportLookupById && docIds.length > 0 ) {
return resolver.fetchDocs()
.then(function () {
angular.forEach(resolver.docs, function (doc) {
Expand Down
4 changes: 2 additions & 2 deletions app/assets/templates/views/wizardModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ <h2>What Search Endpoint do you want to connect to?</h2>
The CSV file should have the headers: <code>Query Text,Doc ID,Doc Position</code>.
Then, all the document fields you want displayed follow as columns with the header being the name of the field.
<pre>
Query Text,Doc ID,Doc Position, Movie Title
Query Text,Doc ID,Doc Position, MovieTitle
star wars,527641,1, Star Wars
star wars,9426,2, Star Wars: The Empire Strikes Back
star wars,1921,3, Star Wars: Return of the Jedi
</pre>
Please note that the additional columns that a Snapshot export has are ignored.
Please note that the additional columns that a Snapshot export file contains are ignored when you import them here.
</span>

<p>Select CSV file to import:</p>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"ngclipboard": "^2.0.0",
"party-js": "^2.2.0",
"popper.js": "^1.16.1",
"splainer-search": "2.30.5",
"splainer-search": "2.30.6",
"tether-shepherd": "latest",
"turbolinks": "^5.2.0",
"vega": "5.26.1"
Expand Down
23 changes: 2 additions & 21 deletions spec/javascripts/angular/services/docCacheSvc_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ describe('Service: docCacheSvc', function () {
var docCacheSvc;
var docResolverSvc;
var ignoredSettings = {
proxyRequests: false
proxyRequests: false,
searchEngine: 'solr'
};

beforeEach(function() {
Expand Down Expand Up @@ -105,26 +106,6 @@ describe('Service: docCacheSvc', function () {
var mockResolver = docResolverSvc.mockResolver;
expect(mockResolver.docs.length).toBe(0);
});

it('resolves even if docId resolver does no work', function() {
checkSetupFromScratch();

docCacheSvc.addIds(['1', '2', '3']);

var called = 0;
docCacheSvc.update(ignoredSettings)
.then(function() {
expect(docCacheSvc.getDoc('1').id).toBe('1');
expect(docCacheSvc.getDoc('2').id).toBe('2');
expect(docCacheSvc.getDoc('3').id).toBe('3');
called++;
});

$rootScope.$apply();
expect(called).toBe(1);
var mockResolver = docResolverSvc.mockResolver;
expect(mockResolver.docs.length).toBe(0);
});
});

describe('invalidation and emptying', function() {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 37c1f3f

Please sign in to comment.