Skip to content

Commit

Permalink
Remove threshold flag for queries (#927)
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh authored Jan 22, 2024
1 parent ee27bc5 commit db03359
Show file tree
Hide file tree
Showing 22 changed files with 27 additions and 312 deletions.
24 changes: 0 additions & 24 deletions app/assets/javascripts/controllers/promptThreshold.js

This file was deleted.

4 changes: 0 additions & 4 deletions app/assets/javascripts/controllers/searchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ angular.module('QuepidApp')
}
});

$scope.overThreshold = function() {
return $scope.query.lastScore && $scope.query.thresholdEnabled &&
($scope.query.lastScore < $scope.query.threshold);
};

$scope.displayed = new DisplayConfig();

Expand Down
27 changes: 0 additions & 27 deletions app/assets/javascripts/controllers/takeThreshold.js

This file was deleted.

26 changes: 0 additions & 26 deletions app/assets/javascripts/services/queriesSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ angular.module('QuepidApp')
self.modified = queryWithRatings.updated_at;


// Threshold properties
self.threshold = queryWithRatings.threshold;
self.thresholdEnabled = queryWithRatings.threshold_enabled;

// Error
self.errorText = '';
Expand Down Expand Up @@ -631,29 +628,6 @@ angular.module('QuepidApp')
});
};

this.setThreshold = function(enabled, threshold) {
var that = this;
var url = 'api/cases/' + caseNo + '/queries/' + that.queryId + '/threshold';
var thresholdJson = {
query: {
threshold: threshold,
threshold_enbl: enabled
}
};

return $http.put(url, thresholdJson)
.then(function() {
that.threshold = threshold;
that.thresholdEnabled = enabled;
}, function(response) {
$log.debug('Failed to set threshold: ', response);
return response;
}).catch(function(response) {
$log.debug('Failed to set threshold');
return response;
});
};

this.reset = function() {
this.errorText = '';
resultsReturned = false;
Expand Down
16 changes: 0 additions & 16 deletions app/assets/templates/views/searchResults.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,13 @@ <h2 class="results-title">

<span class="error-warning glyphicon glyphicon-warning-sign"></span>

<span ng-show="overThreshold()" class="fa-stack fa-lg" title="Threshold of {{query.threshold}} not met.">
<i class="fa fa-circle fa-stack-2x"></i>
<strong class="fa-stack-1x text-danger">
{{query.threshold}}
</strong>
</span>

<span ng-show="query.isNotAllRated()" class="froggy pull-right fa-lg" style="margin-right: 20px;" title="Hop to it! There are unrated results!">
<i class="fas fa-frog fa-stack-2x" data-count="{{ query.currentScore.countMissingRatings }}"></i>
</span>




<span class="toggleSign glyphicon {{query.isToggled() | plusOrMinus}}" ng-hide="isSortingEnabled()" ng-click="query.toggle()"></span>
</div>



<!-- <span ng-click="removeQuery(query.queryId)" class="btn btn-default delete-query glyphicon glyphicon-remove"></span> -->

<div ng-if="query.isToggled()" class="sub-results container clearfix">
<div class="col-ratings query-rating">
<strong>Score All</strong>
Expand Down Expand Up @@ -90,8 +76,6 @@ <h2 class="results-title">

<div class="btn-group">
<query-options query="query"></query-options>
<button type="button" class="btn btn-default btn-sm" ng-controller="TakeThresholdCtrl" ng-click="snapshot.prompt()">Set Threshold
</button>
</div>

<div class="btn-group">
Expand Down
15 changes: 0 additions & 15 deletions app/assets/templates/views/thresholdModal.html

This file was deleted.

24 changes: 0 additions & 24 deletions app/controllers/api/v1/queries/thresholds_controller.rb

This file was deleted.

18 changes: 0 additions & 18 deletions app/lib/analytics/google_analytics/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -558,24 +558,6 @@ def user_bulk_deleted_ratings _user, query
create_event data
end

#
# Creates an event when a user updates query threshold.
#
# @param user, User
# @param query, Query
#
def user_updated_query_threshold _user, query
data = {
category: 'Queries',
action: 'Updated Query Threshold',
label: query.query_text,
value: nil,
bounce: false,
}

create_event data
end

#
# Creates an event when a user updates query scorer.
#
Expand Down
4 changes: 0 additions & 4 deletions app/lib/analytics/tracker/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ def track_query_moved_event user, query, acase
Analytics::GoogleAnalytics.user_moved_query user, query, acase
end

def track_query_threshold_updated_event user, query
Analytics::GoogleAnalytics.user_updated_query_threshold user, query
end

def track_query_notes_updated_event user, query
Analytics::GoogleAnalytics.user_updated_query_notes user, query
end
Expand Down
2 changes: 0 additions & 2 deletions app/models/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# notes :text(65535)
# options :text(65535)
# query_text :string(500)
# threshold :float(24)
# threshold_enbl :boolean
# created_at :datetime not null
# updated_at :datetime not null
# case_id :integer
Expand Down
2 changes: 0 additions & 2 deletions app/views/api/v1/export/cases/_query.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
json.arranged_at query.arranged_at
json.arranged_next query.arranged_next
json.query_text query.query_text
json.threshold query.threshold
json.threshold_enbl query.threshold_enbl
json.options query.options
json.notes query.notes
json.information_need query.information_need
Expand Down
2 changes: 0 additions & 2 deletions app/views/api/v1/queries/_query.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ json.arranged_at query.arranged_at
json.arranged_next query.arranged_next
json.query_id query.id
json.query_text query.query_text
json.threshold query.threshold
json.threshold_enabled query.threshold_enbl
json.options query.options
json.notes query.notes
json.information_need query.information_need
Expand Down
4 changes: 0 additions & 4 deletions app/views/api/v1/queries/thresholds/update.json.jbuilder

This file was deleted.

6 changes: 3 additions & 3 deletions app/views/books/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@
</p>
<% end %>

<h3>Delete Query Doc Pairs Below a Threshold</h3>
<h3>Delete Query Doc Pairs Below a Rank</h3>

<p class="form-text">
Did you populate your book too deeply? Discover you'll never finish rating them? Here you can delete query doc pairs below a certain position (rank).
Did you populate your book too deeply? Discover you'll never finish rating them? Here you can delete query doc pairs below a certain rank (position).
</p>
<%= form_for(@book, url: delete_query_doc_pairs_below_position_book_path(@book), method: :delete, data: { confirm: "Are you sure?" }) do |form| %>
<div class="mb-3">
<%= form.label :position, class: 'form-label' %>
<%= select_tag "position", options_for_select(@book.query_doc_pairs.distinct.pluck(:position).sort), required: true, prompt: "Please select threshold to delete below", class: 'form-control' %>
<%= select_tag "position", options_for_select(@book.query_doc_pairs.distinct.pluck(:position).sort), required: true, prompt: "Please select rank to delete below", class: 'form-control' %>
</div>
<p>
<div class="actions">
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
resource :notes, only: [ :show, :update ]
resource :options, only: [ :show, :update ]
resource :position, only: [ :update ]
resource :threshold, only: [ :update ]
resource :ratings, only: [ :update, :destroy ] # not actually a singular resource, doc_id in json payload
end

Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20240121134401_drop_threshold_enbl_from_queries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class DropThresholdEnblFromQueries < ActiveRecord::Migration[7.1]
# thresholds was a feature that was added in the early years of Quepid
# but has never taken off. Removing to simplify code base.
def change
remove_column :queries, :threshold_enbl
remove_column :queries, :threshold
end
end
4 changes: 1 addition & 3 deletions db/schema.rb

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

43 changes: 0 additions & 43 deletions spec/javascripts/angular/services/queriesSvc_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -830,49 +830,6 @@ describe('Service: queriesSvc', function () {
expect(bestDocs[1].id).toEqual('doc1');
});

/** Threshold Testing **/
describe('- Threshold Tests: ', function() {
var mockThresholdResponse = {
queryId: 1,
threshold: 20,
threshold_enabled: true
};
var testQuery;

beforeEach(function() {
setupQuerySvc();
testQuery = queriesSvc.queries['0'];
});

it('Setting threshold on backend', function() {
$httpBackend.expectPUT('api/cases/2/queries/' + testQuery.queryId + '/threshold')
.respond(200, mockThresholdResponse);
var testNewThreshold = 20;

testQuery.setThreshold(true, testNewThreshold)
.then(function() {
expect(testQuery.thresholdEnabled).toEqual(true);
expect(testQuery.threshold).toEqual(testNewThreshold);
});

$httpBackend.flush();
});

it('Disabling threshold on backend', function() {
mockThresholdResponse.threshold_enabled = false;

$httpBackend.expectPUT('api/cases/2/queries/' + testQuery.queryId + '/threshold')
.respond(200, mockThresholdResponse);

testQuery.setThreshold(false)
.then(function() {
expect(testQuery.thresholdEnabled).toEqual(false);
});

$httpBackend.flush();
});
});

describe('- Max Score Tests: ', function() {
var explain1 = {'match':true,'value':1.0,'description':'weight(text:foo)'};
var explain2 = {'match':true,'value':2.0,'description':'weight(text:foo)'};
Expand Down
Loading

0 comments on commit db03359

Please sign in to comment.