Skip to content

Commit

Permalink
Add term filter to summary of authors_not_graduated data
Browse files Browse the repository at this point in the history
Why these changes are being introduced:

Report#data_authors_not_graduated does not include a grad_date filter,
so all theses with ungraduated authors are shown for each term
instead of just the theses for the corresponding term.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/ETD-429

How this addresses that need:

This adds the term filter into Report#data_authors_not_graduated

Side effects of this change:

N/A.
  • Loading branch information
jazairi committed Mar 10, 2022
1 parent f6f6a28 commit d3137d7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ def data_authors_not_graduated
row_data = {}
terms = Thesis.all.pluck(:grad_date).uniq.sort
terms.each do |term|
row_data[term] = Thesis.with_files.includes(authors: :user).includes(:departments).select do |t|
!t.authors_graduated?
end.uniq.count
row_data[term] = Thesis.with_files.where('grad_date = ?', term).includes(authors: :user).includes(:departments)
.reject(&:authors_graduated?).count
end
{
label: 'Authors not graduated',
Expand Down
22 changes: 22 additions & 0 deletions test/models/report_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ class ReportTest < ActiveSupport::TestCase
assert_equal result['departments'][0][:data].values, [0, 3, 0, 0, 0, 0, 0, 4, 0]
end

test 'index includes summary data of authors not graduated' do
thesis = theses(:bachelor)
another_thesis = theses(:published)
assert_not_equal thesis.grad_date, another_thesis.grad_date
assert thesis.files?
assert another_thesis.files?

a = thesis.authors.first
a.graduation_confirmed = false
a.save
assert_not thesis.authors_graduated?

a = another_thesis.authors.first
a.graduation_confirmed = false
a.save
assert_not another_thesis.authors_graduated?

r = Report.new
result = r.index_data
assert_equal result['summary'][5][:data].values, [0, 1, 0, 0, 0, 0, 0, 1, 0]
end

# ~~~~ Term detail report
test 'term detail includes a breakdown of departments' do
r = Report.new
Expand Down

0 comments on commit d3137d7

Please sign in to comment.