Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace ActiveFedora where with Valkyrized where #4910

Merged
merged 2 commits into from May 6, 2021
Merged

Conversation

elrayle
Copy link
Contributor

@elrayle elrayle commented May 4, 2021

Partially addresses Issue #3820

Establishes the pattern for how to replace calls to ActiveFedora::Base #where method.

Establishes a new service class that searches solr to get object IDs and then uses Hyrax.query_service get the objects. The method name that is the equivalent of the ActiveFedora where method is .find_for_model_by_field_pairs.

This allows for other types of queries for solr to be constructed as needed at a later time.

@samvera/hyrax-code-reviewers

no-reply
no-reply previously approved these changes May 4, 2021
end

def collection_type_gids_that_disallow_multiple_membership
Hyrax::CollectionType.gids_that_do_not_allow_multiple_membership
Hyrax::CollectionType.gids_that_do_not_allow_multiple_membership.map(&:to_s)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's going on here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests initially failed when refactoring for the new approach which required this change. But the final refactor really doesn't need this. So I set it back to what it was.

results = solr_service.query(query)
ids = results.map(&:id)
return query_service.find_many_by_ids(ids: ids) if use_valkyrie
ids.map { |id| query_service.find_by_alternate_identifier(alternate_identifier: id.to_str, use_valkyrie: false) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the advantage of using the valkyrie query service?

would there be fewer risks if we stuck with the the existing ActiveFedora::Base#where implementation in the case where what we want is to query AF objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to use AF where unless use_valkyrie is true.

@no-reply no-reply dismissed their stale review May 4, 2021 21:46

oops, meant to just comment.

@elrayle elrayle force-pushed the fix/3820_AF_where branch 2 times, most recently from 7af0aa6 to c7af5b2 Compare May 5, 2021 13:37
Copy link
Contributor

@jeremyf jeremyf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great pattern and helps create the inflection point. I "approve" this contingent on pending .map(&:to_s) question

Results were expected to be an array, but before this commit, an enumeration was returned when using Valkyrie.  This ensures that an array is returned whether working wtih AF or Valkyrie.

Also removes need to convert to string per requested change during review.
@elrayle elrayle added this to Ready for Review in Hyrax-Valkyrization May 5, 2021
@jeremyf jeremyf merged commit b077bd4 into main May 6, 2021
@jeremyf jeremyf deleted the fix/3820_AF_where branch May 6, 2021 12:56
@elrayle elrayle moved this from Ready for Review to DONE in Hyrax-Valkyrization May 6, 2021
@elrayle elrayle moved this from DONE to Ready to be Archived in Hyrax-Valkyrization Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Hyrax-Valkyrization
Ready to be Archived
Development

Successfully merging this pull request may close these issues.

None yet

3 participants