Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Jan 30, 2024
1 parent da5597e commit 366678a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ angular.module('QuepidApp')

ctrl.theCase = theCase;
ctrl.supportsDetailedExport = supportsDetailedExport;
ctrl.isProcessingFile = isProcessingFile;

// If called from the cases listing page, then we need the call back with the bootstrap,
// otherwise on the main page the querySnapshotSvc.snapshots was bootstrapped.
Expand Down Expand Up @@ -50,7 +49,7 @@ angular.module('QuepidApp')
};


function isProcessingFile() {
ctrl.isProcessingFile = function () {
if (ctrl.options.snapshot){
var desiredSnapshot = null;
angular.forEach(ctrl.snapshots, function(snapshot) {
Expand All @@ -67,6 +66,6 @@ angular.module('QuepidApp')
}
}
return false;
}
};
}
]);
7 changes: 5 additions & 2 deletions app/assets/javascripts/services/querySnapshotSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ angular.module('QuepidApp')
};

return $http.post('api/cases/' + caseNo + '/snapshots', saved)
.then(function() {
version++;
.then(function(response) {
return addSnapshotResp([response.data])
.then(function() {
version++;
});
});
};

Expand Down
25 changes: 15 additions & 10 deletions app/controllers/api/v1/books_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,30 @@ def show

# Only return rateable judgements, filter out the unrateable ones.
# unique_raters = @book.judgements.rateable.preload(:user).collect(&:user).uniq
unique_raters = @book.judges.merge(Judgement.rateable)
#unique_raters = @book.judges.merge(Judgement.rateable)
unique_judge_ids = @book.query_doc_pairs.joins(:judgements)
.distinct.pluck(:user_id)


puts 'HERE COME THE RATERS'
pp unique_raters

# this logic about using email versus name is kind of awful. Think about user.full_name or user.identifier?
unique_raters.each do |rater|
csv_headers << make_csv_safe(if rater.nil?
'Unknown'
unique_judges = []
unique_judge_ids.each do |judge_id|
judge = User.find(judge_id) unless judge_id.nil?
unique_judges << judge
csv_headers << make_csv_safe(if judge.nil?
'anonymous'
else
rater.name.presence || rater.email
judge.name.presence || judge.email
end)
end

@csv_array << csv_headers
@book.query_doc_pairs.each do |qdp|
query_doc_pairs = @book.query_doc_pairs.include(:judgements)
query_doc_pairs.each do |qdp|
row = [ make_csv_safe(qdp.query_text), qdp.doc_id ]
unique_raters.each do |rater|
judgement = qdp.judgements.detect { |j| j.user == rater }
unique_judges.each do |judge|
judgement = qdp.judgements.detect { |j| j.user == judge }
rating = judgement.nil? ? '' : judgement.rating

row.append rating
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/api/v1/snapshots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ def create
# rubocop:enable Layout/LineLength

def destroy
# SnapshotDoc.joins(snapshot_query: :snapshot)
# .where(snapshot_queries: { snapshot: @snapshot })
# .delete_all
@snapshot.snapshot_docs.delete_all
SnapshotDoc.joins(snapshot_query: :snapshot)
.where(snapshot_queries: { snapshot: @snapshot })
.delete_all
@snapshot.snapshot_queries.delete_all
@snapshot.destroy
Analytics::Tracker.track_snapshot_deleted_event current_user, @snapshot
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/judgements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def index
bool = ActiveRecord::Type::Boolean.new
@shallow = bool.deserialize(params[:shallow] || true )

@judgements = @book.judgements.includes([ :query_doc_pair, :user ])
@judgements = @book.judgements.includes([ :query_doc_pair, :user ]).order('query_doc_pair_id')
end

def show
Expand Down
4 changes: 0 additions & 4 deletions app/models/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class Book < ApplicationRecord
belongs_to :selection_strategy
belongs_to :scorer
has_many :query_doc_pairs, dependent: :destroy, autosave: true
has_many :ordered_judgements, -> { order('query_doc_pair_id') },
through: :query_doc_pairs,
dependent: :destroy,
class_name: 'Judgement'

has_many :judgements,
through: :query_doc_pairs,
Expand Down
2 changes: 1 addition & 1 deletion spec/javascripts/angular/services/querySnapshotSvc_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Service: querySnapshotSvc', function () {
$httpBackend.verifyNoOutstandingExpectation();
});

it('doesnt update version if same case', function() {
it('does not update version if same case', function() {
var priorVersion = querySnapshotSvc.version();
querySnapshotSvc.bootstrap(2);
querySnapshotSvc.bootstrap(2);
Expand Down

0 comments on commit 366678a

Please sign in to comment.