{"action":"closed","issue":{"url":"https://api.github.com/repos/samvera/hyrax/issues/3349","repository_url":"https://api.github.com/repos/samvera/hyrax","labels_url":"https://api.github.com/repos/samvera/hyrax/issues/3349/labels{/name}","comments_url":"https://api.github.com/repos/samvera/hyrax/issues/3349/comments","events_url":"https://api.github.com/repos/samvera/hyrax/issues/3349/events","html_url":"https://github.com/samvera/hyrax/issues/3349","id":373556653,"node_id":"MDU6SXNzdWUzNzM1NTY2NTM=","number":3349,"title":"Performance issues with ActiveFedora.where","user":{"login":"elrayle","id":6855473,"node_id":"MDQ6VXNlcjY4NTU0NzM=","avatar_url":"https://avatars0.githubusercontent.com/u/6855473?v=4","gravatar_id":"","url":"https://api.github.com/users/elrayle","html_url":"https://github.com/elrayle","followers_url":"https://api.github.com/users/elrayle/followers","following_url":"https://api.github.com/users/elrayle/following{/other_user}","gists_url":"https://api.github.com/users/elrayle/gists{/gist_id}","starred_url":"https://api.github.com/users/elrayle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elrayle/subscriptions","organizations_url":"https://api.github.com/users/elrayle/orgs","repos_url":"https://api.github.com/users/elrayle/repos","events_url":"https://api.github.com/users/elrayle/events{/privacy}","received_events_url":"https://api.github.com/users/elrayle/received_events","type":"User","site_admin":false},"labels":[{"id":678001188,"node_id":"MDU6TGFiZWw2NzgwMDExODg=","url":"https://api.github.com/repos/samvera/hyrax/labels/Effort:%20Minor","name":"Effort: Minor","color":"89b776","default":false},{"id":505053953,"node_id":"MDU6TGFiZWw1MDUwNTM5NTM=","url":"https://api.github.com/repos/samvera/hyrax/labels/refactoring","name":"refactoring","color":"f7c6c7","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/samvera/hyrax/milestones/1","html_url":"https://github.com/samvera/hyrax/milestone/1","labels_url":"https://api.github.com/repos/samvera/hyrax/milestones/1/labels","id":2210731,"node_id":"MDk6TWlsZXN0b25lMjIxMDczMQ==","number":1,"title":"Backlog","description":"","creator":{"login":"mjgiarlo","id":131982,"node_id":"MDQ6VXNlcjEzMTk4Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/131982?v=4","gravatar_id":"","url":"https://api.github.com/users/mjgiarlo","html_url":"https://github.com/mjgiarlo","followers_url":"https://api.github.com/users/mjgiarlo/followers","following_url":"https://api.github.com/users/mjgiarlo/following{/other_user}","gists_url":"https://api.github.com/users/mjgiarlo/gists{/gist_id}","starred_url":"https://api.github.com/users/mjgiarlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjgiarlo/subscriptions","organizations_url":"https://api.github.com/users/mjgiarlo/orgs","repos_url":"https://api.github.com/users/mjgiarlo/repos","events_url":"https://api.github.com/users/mjgiarlo/events{/privacy}","received_events_url":"https://api.github.com/users/mjgiarlo/received_events","type":"User","site_admin":false},"open_issues":256,"closed_issues":161,"state":"open","created_at":"2016-12-21T19:45:35Z","updated_at":"2018-11-08T17:12:57Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2018-10-24T15:58:08Z","updated_at":"2018-11-08T17:12:57Z","closed_at":"2018-11-08T17:12:57Z","author_association":"CONTRIBUTOR","body":"### Descriptive summary\r\n\r\nActiveFedora::Base.where uses solr to find resources and then resumes all the results from Fedora.  In many cases, it is not necessary to have the Fedora objects.  This applies generally to Hyrax, but this issue uses one instance as an example.\r\n\r\nThis issue should also identify other places where ActiveFedora::Base.where is used to determine if those can also be converted to pure solr.\r\n\r\n### Rationale\r\n\r\nResuming objects from Fedora is expensive from a performance perspective and should only be done when needed.\r\n\r\n### Expected behavior\r\n\r\nGetting a count of objects in a collection should be done completely through solr.\r\n\r\n```\r\ndef total_items\r\n    ActiveFedora::SolrService.query(\"member_of_collection_ids_ssim:#{id}\", rows: 100000000).count\r\nend\r\n```\r\n\r\nNote: Not sure how to tell SolrService to return all matches.  I think it defaults to something like the first 10 rows.  So in the example, I made the rows requested very large, but there may be a better way. \r\n\r\n### Actual behavior\r\n\r\nGetting a count of objects in a collection is performed with ActiveFedora.where which searches solr to find objects and then resumes them from Fedora.\r\n\r\n```\r\ndef total_items\r\n    ActiveFedora::Base.where(\"member_of_collection_ids_ssim:#{id}\").count\r\nend\r\n```\r\n\r\nhttps://github.com/samvera/hyrax/blob/master/app/presenters/hyrax/collection_presenter.rb#L67-L69\r\n\r\nNOTE: The other uses of ActiveFedora::Base.where for counting in this presenter cannot be changed as solr docs do not support the accessible_by method.  I don't know if there is an equivalent approach that can be used to make those pure solr queries.\r\n\r\n### Steps to reproduce the behavior\r\n\r\n1. Run spec testing #total_items method in [collection_presenter_spec.rb](https://github.com/samvera/hyrax/blob/master/spec/presenters/hyrax/collection_presenter_spec.rb#L135-L153)\r\n2. confirm the test passes before and after the change\r\n\r\n"}}
{"actor":{"display_login":"no-reply"}}