Skip to content

Commit

Permalink
Merge branch 'main' into judge_judy
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed May 2, 2024
2 parents 84f39f8 + 6b25007 commit 110cb97
Show file tree
Hide file tree
Showing 41 changed files with 416 additions and 119 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 7.16.1 - 2024-04-09

### Bugs

* You can delete a user who has existing judgements, and then that messes up the main Books page because their judgements hang around. Now you are warned about this, and you can choose to make their judgements anonymous. (or just Lock their user account). https://github.com/o19s/quepid/pull/999 by @epugh.

## 7.16.0 - 2024-03-28

### Features

* Now have a dropdown for Books similar to Cases that leverages our existing tracking of what books you have viewed. https://github.com/o19s/quepid/pull/986 by @epugh.

* We now run scorers over queries that have no ratings and queries that are ZSR. This lets us have smarter logic about how you want to score those situations. https://github.com/o19s/quepid/pull/993 by @epugh.

### Improvements

* One less query to determine what a user has access to via being an owner or a member of a team while ensuring no duplicate cases/books show up. https://github.com/o19s/quepid/pull/982 by @epugh with input from @reid-rigo.

* Remove extranous faraday logs when running tests. https://github.com/o19s/quepid/pull/983 by @epugh with input form @reid-rigo fixes https://github.com/o19s/quepid/issues/964.

* Nicer onboarding using TMDB dataset for Algolia users. https://github.com/o19s/quepid/pull/987 by @chuckmeyer.

### Bugs

* Book Importing was broken. Plus now we have nicer formatted error message when you validate a book to import. https://github.com/o19s/quepid/pull/989 by @epugh.



## 7.15.1 - 2024-03-13

Expand Down
13 changes: 6 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ GEM
activemodel (= 7.1.3)
activesupport (= 7.1.3)
timeout (>= 0.4.0)
activerecord-import (1.5.1)
activerecord-import (1.6.0)
activerecord (>= 4.2)
activestorage (7.1.3)
actionpack (= 7.1.3)
Expand Down Expand Up @@ -103,7 +103,7 @@ GEM
base64 (0.2.0)
bcrypt (3.1.20)
benchmark-ips (2.13.0)
bigdecimal (3.1.6)
bigdecimal (3.1.7)
bindata (2.4.15)
bindex (0.8.1)
bootsnap (1.18.3)
Expand Down Expand Up @@ -158,8 +158,7 @@ GEM
actionmailer (>= 5.0)
devise (>= 4.6)
docile (1.4.0)
drb (2.2.0)
ruby2_keywords
drb (2.2.1)
erubi (1.12.0)
execjs (2.9.1)
faraday (2.9.0)
Expand All @@ -180,7 +179,7 @@ GEM
hashie (5.0.0)
heapy (0.2.0)
thor
i18n (1.14.1)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
importmap-rails (2.0.1)
actionpack (>= 6.0.0)
Expand Down Expand Up @@ -217,7 +216,7 @@ GEM
addressable (~> 2.8)
letter_opener (1.9.0)
launchy (>= 2.2, < 3)
listen (3.8.0)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
local_time (3.0.2)
Expand All @@ -234,7 +233,7 @@ GEM
memory_profiler (1.0.1)
mini_histogram (0.3.1)
mini_mime (1.1.5)
minitest (5.21.2)
minitest (5.22.3)
minitest-reporters (1.6.1)
ansi
builder
Expand Down
Binary file removed app/assets/images/algolia-icon.png
Binary file not shown.
Binary file added app/assets/images/algolia.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ angular.module('QuepidApp')
annotation: ctrl.annotationModel,
score: {
all_rated: ctrl.selectedCase.lastScore.all_rated,
score: ctrl.selectedCase.lastScore.score,
try_id: ctrl.selectedCase.lastScore.try_id,
queries: ctrl.selectedCase.lastScore.queries,
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ angular.module('QuepidApp')
var ctrl = this;

ctrl.import = { loading: false };


ctrl.ok = function () {
var file = document.getElementById('caseJson').files[0];
Expand All @@ -40,7 +39,6 @@ angular.module('QuepidApp')
let errorMessage = 'Unable to import Case: ';
errorMessage += response.status;
errorMessage += ' - ' + response.statusText;
//errorMessage += ' - ' + JSON.stringify(response.data);
// Convert JSON to nice error messages
const errorMessages = Object.entries(response.data).map(([field, errors]) => {
const formattedField = field.charAt(0).toUpperCase() + field.slice(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ angular.module('QuepidApp')
'$scope',
'$log',
'flash',
'queriesSvc',
function (
$uibModal,
$scope,
$log,
flash
flash,
queriesSvc
) {
var ctrl = this;
ctrl.query = $scope.query;
Expand Down Expand Up @@ -42,6 +44,8 @@ angular.module('QuepidApp')
ctrl.query.saveOptions(JSON.parse(value))
.then(function() {
flash.success = 'Query options saved successfully.';
$log.info('rescoring queries after changing query options');
queriesSvc.updateScores();
}, function() {
flash.error = 'Unable to save query options.';
});
Expand Down
46 changes: 37 additions & 9 deletions app/assets/javascripts/controllers/headerCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,44 @@ angular.module('QuepidApp')
'$rootScope',
'$scope',
'$route',
'$uibModal',
'caseSvc', 'caseTryNavSvc',
'caseSvc',
'bookSvc',
'caseTryNavSvc',
function(
$rootScope,
$scope,
$route,
$uibModal,
caseSvc,
bookSvc,
caseTryNavSvc
) {
$rootScope.isRailsGoingToAngular = isRailsGoingToAngular;

$scope.headerScope = {};
$scope.headerScope.dropdownCases = [];
$scope.headerScope.dropdownBooks = [];
$scope.headerScope.casesCount = 0;
$scope.headerScope.booksCount = 0;
$scope.theCase = null;

$scope.headerScope.goToCase = goToCase;
$scope.headerScope.createBookLink = createBookLink;

angular.forEach(['fetchedDropdownCasesList'], function (eventName) {
$scope.$on(eventName, function() {
$scope.headerScope.dropdownCases = caseSvc.dropdownCases;
$scope.headerScope.casesCount = caseSvc.casesCount;
});

$scope.$on('fetchedDropdownCasesList', function() {
$scope.headerScope.dropdownCases = caseSvc.dropdownCases;
$scope.headerScope.casesCount = caseSvc.casesCount;
});

$scope.$on('fetchedDropdownBooksList', function() {
$scope.headerScope.dropdownBooks = bookSvc.dropdownBooks;
$scope.headerScope.booksCount = bookSvc.booksCount;
});

$scope.$on('associateBook', function() {
bookSvc.fetchDropdownBooks();
});


angular.forEach(['updatedCasesList', 'caseRenamed'], function (eventName) {
$scope.$on(eventName, function() {
Expand All @@ -40,14 +54,28 @@ angular.module('QuepidApp')

// Necessary when the first page isn't the main case page
caseSvc.fetchDropdownCases();
bookSvc.fetchDropdownBooks();

function goToCase($event, aCase) {
$event.preventDefault();
caseTryNavSvc.navigateTo({'caseNo': aCase.caseNo, 'tryNo': aCase.lastTry});
}
}

function isRailsGoingToAngular() {
return !( angular.isDefined($route.current) && angular.isDefined($route.current.$$route) );
}

$scope.$on('caseSelected', function() {
$scope.theCase = caseSvc.getSelectedCase();
});

function createBookLink() {
if ($scope.theCase){
const teamIds = $scope.theCase.teams.map(function(team) {
return `&team_ids[]=${team.id}`;
});
return `books/new?book[scorer_id]=${$scope.theCase.scorerId}${teamIds}&origin_case_id=${$scope.theCase.caseNo}`;
}
}
}
]);
18 changes: 16 additions & 2 deletions app/assets/javascripts/factories/ScorerFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
self.owned = data.owned;
self.ownerId = data.owner_id;
self.ownerName = data.owner_name;

self.scorerId = data.scorer_id;
self.communal = data.communal;

self.teams = data.teams || [];

// Functions
Expand Down Expand Up @@ -567,6 +567,9 @@
function score(query, total, docs, bestDocs, options) {
bestDocs = bestDocs || [];

/**
Now allowing the scorer to be run regardless of if we have ratings or a ZSR.
The special logic for those situations is after running the scorer.
if (bestDocs.length === 0 || docs.length === 0) {
let label = null;
// Don't score if there are no ratings
Expand All @@ -581,6 +584,7 @@
d.resolve(label);
return d.promise;
}
**/

var maxScore = self.maxScore();
return self.runCode(
Expand All @@ -591,6 +595,16 @@
undefined,
options
).then(function(calcScore){
//window.alert('query ' + query.queryText + ' socre:' + calcScore);
// Set to ZSR if there are no docs
if (calcScore === null){
if (docs.length === 0) {
return 'zsr';
}
if (bestDocs.length === 0) {
return '--';
}
}
if (angular.isNumber(calcScore)) {
if (calcScore < 0 && calcScore === maxScore) {
return null;
Expand Down
23 changes: 22 additions & 1 deletion app/assets/javascripts/services/bookSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ angular.module('QuepidApp')
'$http',
'broadcastSvc',
function bookSvc($http, broadcastSvc) {
this.books = [];
this.books = [];
this.dropdownBooks = [];
this.booksCount = 0;

var Book = function(id, name) {
this.id = id;
Expand Down Expand Up @@ -132,5 +134,24 @@ angular.module('QuepidApp')
console.log('refreshed ratings' + response.data);
});
};

this.fetchDropdownBooks = function() {
var self = this;
self.dropdownBooks.length = 0;
return $http.get('api/dropdown/books')
.then(function(response) {
self.booksCount = response.data.books_count;

angular.forEach(response.data.books, function(dataBook) {
let book = self.constructFromData(dataBook);

if(!contains(self.dropdownBooks, book)) {
self.dropdownBooks.push(book);
}
});

broadcastSvc.send('fetchedDropdownBooksList', self.dropdownBooks);
});
};
}
]);
1 change: 1 addition & 0 deletions app/assets/javascripts/services/caseSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ angular.module('QuepidApp')

theCase.bookId = bookId;
theCase.bookName = response.book_name;
broadcastSvc.send('associateBook', svc.dropdownBooks);
}, function() {
caseTryNavSvc.notFound();
});
Expand Down
10 changes: 5 additions & 5 deletions app/assets/javascripts/services/settingsSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,16 @@ angular.module('QuepidApp')
headerType: 'Custom',
customHeaders: [
'{',
' "x-algolia-application-id": "YOUR_ALGOLIA_APPLICATION_ID",',
' "x-algolia-api-key": "YOUR_ALGOLIA_API_KEY"',
' "x-algolia-application-id": "OKF83BFQS4",',
' "x-algolia-api-key": "2ee1381ed11d3fe70b60605b1e2cd3f4"',
'}'
].join('\n'),
idField: 'objectID',
titleField: 'name',
additionalFields: [],
titleField: 'title',
additionalFields: ['overview', 'cast', 'thumb:poster_path'],
numberOfRows: 10,
searchEngine: 'algolia',
searchUrl: 'https://78J6LMFN9N-dsn.algolia.net/1/indexes/dev_quepid/query',
searchUrl: 'https://OKF83BFQS4-dsn.algolia.net/1/indexes/movies_demo_quepid/query',
urlFormat: 'https://<APPLICATION-ID>-dsn.algolia.net/1/indexes/<index>/query',
proxyRequests: true,
basicAuthCredential: ''
Expand Down
6 changes: 4 additions & 2 deletions app/assets/javascripts/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ this.setupTour = function() {

tour.addStep('tune', {
title: 'Tune Relevance',
text: `This is where all the magic happens!<br />If you are not familiar with how this work, read the <a href="http://quepid.com/docs/#tuning" target="_blank" title="Knowledge Base">Tuning Relevance</a> section in the Knowledge Base.<br />TL;DR: always make sure this <code>#$query##</code> exists somewhere.<br />Let\s make change this up and see what happens.<br />If you are using Solr, change the query sandbox to: <code>q=#$query##&defType=edismax&qf=title overview</code><br />or to <code>{ \
text: `This is where all the magic happens!<br />If you are not familiar with how this work, read the <a href="http://quepid.com/docs/#tuning" target="_blank" title="Knowledge Base">Tuning Relevance</a> section in the Knowledge Base.<br />TL;DR: always make sure this <code>#$query##</code> exists somewhere.<br />Let's change this up and see what happens.<br />If you are using Solr, change the query sandbox to: <code>q=#$query##&defType=edismax&qf=title overview</code><br />or to <code>{ \
"query": { \
"match": { \
"title": "#$query##" \
} \
} \
}</code> if you are using Elasticsearch<br />(adjust appropriately if you are not using the demo case).`,
}</code> if you are using Elasticsearch,<br /> or add <code>"restrictSearchableAttributes": [ \
"title" \
]</code> for Algolia, (adjust appropriately if you are not using the demo case).`,
attachTo: '.pane_east left',
advanceOn: '#tune-relevance-link a click',
buttons: [{
Expand Down
2 changes: 1 addition & 1 deletion app/assets/templates/views/common/flash.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="flash-messages">
<div flash-alert active-class="in alert" class="flash fade">
<button type="button" class="close pull-left" ng-click="hide()">&times;</button>
<span class="alert-message">{{flash.message}}</span>
<span class="alert-message" ng-bind-html="flash.message"></span>
</div>

<ng-include src="'views/cases/search_flash.html'"></ng-include>
Expand Down
2 changes: 1 addition & 1 deletion app/assets/templates/views/wizardModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h2>What Search Endpoint do you want to connect to?</h2>
<div style="text-align: center;">
<label style="margin-right: 25px;">
<input type="radio" value="algolia" ng-model="pendingWizardSettings.searchEngine" ng-change="changeSearchEngine()">
<img ng-src="images/algolia-icon.png" alt='Algolia' height="50px" />
<img ng-src="images/algolia.png" alt='Algolia' width="150px" />
</label>
</div>

Expand Down

0 comments on commit 110cb97

Please sign in to comment.