Skip to content

Fix bug in consented_to_proquest scope ignoring null values#1108

Merged
jazairi merged 1 commit intomainfrom
etd-588-bugfix-for-conflict-status
Jan 18, 2023
Merged

Fix bug in consented_to_proquest scope ignoring null values#1108
jazairi merged 1 commit intomainfrom
etd-588-bugfix-for-conflict-status

Conversation

@jazairi
Copy link
Copy Markdown
Contributor

@jazairi jazairi commented Jan 18, 2023

Why these changes are being introduced:

The consented_to_proquest scope returns thesis for which all authors have a proquest_allowed value of true and not false. This ignores author records with a null proquest_allowed value, so if a thesis has multiple authors and at least one of them has not selected an opt-in status, it will incorrectly be flagged as ready for ProQuest export.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/ETD-588
https://mitlibraries.atlassian.net/browse/ETD-603

How this addresses that need:

This chains an additional excluding call to the scope that checks for authors with null proquest_allowed, and adds regression tests to confirm the correct behavior.

Side effects of this change:

The additional excluding call is a bit ugly, but after fiddling with it for a while I decided it was more important to land a working solution than an elegant one.

Developer

  • All new ENV is documented in README
  • All new ENV has been added to Heroku Pipeline, Staging and Prod
  • ANDI or Wave has been run in accordance to
    our guide and
    all issues introduced by these changes have been resolved or opened as new
    issues (link to those issues in the Pull Request details above)
  • Stakeholder approval has been confirmed (or is not needed)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated or is unnecessary
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

Requires database migrations?

NO

Includes new or updated dependencies?

NO

@mitlib mitlib temporarily deployed to thesis-submit-pr-1108 January 18, 2023 19:24 Inactive
Why these changes are being introduced:

The consented_to_proquest scope returns thesis for which all authors
have a proquest_allowed value of true and not false. This ignores
author records with a null proquest_allowed value, so if a thesis
has multiple authors and at least one of them has not selected
an opt-in status, it will incorrectly be flagged as ready
for ProQuest export.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/ETD-588
https://mitlibraries.atlassian.net/browse/ETD-603

How this addresses that need:

This chains an additional `excluding` call to the scope that checks
for authors with null proquest_allowed, and adds regression tests
to confirm the correct behavior.

Side effects of this change:

The additional `excluding` call is a bit ugly, but after fiddling
with it for a while I decided it was more important to land a
working solution than an elegant one.
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 18, 2023

Coverage Status

Coverage: 97.59%. Remained the same when pulling 044b7f5 on etd-588-bugfix-for-conflict-status into b2d22bf on main.

@jazairi jazairi force-pushed the etd-588-bugfix-for-conflict-status branch from 5575951 to 044b7f5 Compare January 18, 2023 19:29
@jazairi jazairi temporarily deployed to thesis-submit-pr-1108 January 18, 2023 19:29 Inactive
@JPrevost JPrevost self-assigned this Jan 18, 2023
@jazairi jazairi merged commit 2212178 into main Jan 18, 2023
@jazairi jazairi deleted the etd-588-bugfix-for-conflict-status branch January 18, 2023 19:42
jazairi added a commit that referenced this pull request Jan 19, 2023
Why these changes are being introduced:

This is a similar issue to the one solved in #1108, but in the
not_consented_to_proquest scope. Here, the scope excludes all
theses with an author ProQuest consent value of 'true'. This
works in most cases, except when one author has opted in and
another hasn't, that thesis should still be partially harvested.
With the current logic, it will not show up in the export preview
because the scope sees a 'true' consent value and thus excludes
the thesis.

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/ETD-603

How this addresses that need:

This inverts the logic of the not_consented_to_proquest scope.
Instead of excluding theses with at least one ProQuest consent
value of true, it includes theses with at least one ProQuest consent
value of false or nil, using the 'or' method to return the union.

Side effects of this change:

Since 'includes' is not compatible with the 'or' method, the scope
now uses 'left_joins' to load the author records. This also means
that the the result will be an ActiveRecord assocation rather than
an array. ActiveJob does not accept associations as params, so
we are now casting the params as arrays. I've done with this with
both the full and partial export sets to avoid confusion, even
though it's only needed at this stage for the partial export set.
jazairi added a commit that referenced this pull request Jan 19, 2023
Why these changes are being introduced:

This is a similar issue to the one solved in #1108, but in the
not_consented_to_proquest scope. Here, the scope excludes all
theses with an author ProQuest consent value of 'true'. This
works in most cases, except when one author has opted in and
another hasn't, that thesis should still be partially harvested.
With the current logic, it will not show up in the export preview
because the scope sees a 'true' consent value and thus excludes
the thesis.

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/ETD-603

How this addresses that need:

This inverts the logic of the not_consented_to_proquest scope.
Instead of excluding theses with at least one ProQuest consent
value of true, it includes theses with at least one ProQuest consent
value of false or nil, using the 'or' method to return the union.

Side effects of this change:

Since 'includes' is not compatible with the 'or' method, the scope
now uses 'left_joins' to load the author records. This also means
that the the result will be an ActiveRecord assocation rather than
an array. ActiveJob does not accept associations as params, so
we are now casting the params as arrays. I've done with this with
both the full and partial export sets to avoid confusion, even
though it's only needed at this stage for the partial export set.
jazairi added a commit that referenced this pull request Jan 19, 2023
Why these changes are being introduced:

This is a similar issue to the one solved in #1108, but in the
not_consented_to_proquest scope. Here, the scope excludes all
theses with an author ProQuest consent value of 'true'. This
works in most cases, except when one author has opted in and
another hasn't, that thesis should still be partially harvested.
With the current logic, it will not show up in the export preview
because the scope sees a 'true' consent value and thus excludes
the thesis.

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/ETD-603

How this addresses that need:

This inverts the logic of the not_consented_to_proquest scope.
Instead of excluding theses with at least one ProQuest consent
value of true, it includes theses with at least one ProQuest consent
value of false or nil, using the 'or' method to return the union.

Side effects of this change:

Since 'includes' is not compatible with the 'or' method, the scope
now uses 'left_joins' to load the author records. This also means
that the the result will be an ActiveRecord assocation rather than
an array. ActiveJob does not accept associations as params, so
we are now casting the params as arrays. I've done with this with
both the full and partial export sets to avoid confusion, even
though it's only needed at this stage for the partial export set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants