-
Notifications
You must be signed in to change notification settings - Fork 81
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
results: added support for drafts #1700
base: master
Are you sure you want to change the base?
results: added support for drafts #1700
Conversation
@@ -69,3 +69,32 @@ def get_value_service(self, value): | |||
def pick(self, identity, resolved_rec): | |||
"""Pick fields defined in the entity resolver.""" | |||
return resolved_rec | |||
|
|||
class RDMRecordList(RecordList): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue was that drafts are searched through the records service, which in turn uses the default RecordList
class to project the search results.
The default implementation uses self._service.record_cls
unconditionally, which in turn projects the result always to a record. This is not correct if the service shares the search for records and drafts. For instance, an unpublished draft always had the attribute is_draft=False
because the attribute is_draft
of a Record
is always set to False
.
* Added support for drafts in the results list
ae88913
to
6cccfab
Compare
for hit in self._results: | ||
# Load dump | ||
record_dict = hit.to_dict() | ||
if record_dict["is_published"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: wouldn't it be better to rely on the is_draft
property? Though I think this should be a ConstantField
systemfield so that it makes it to the indexed document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's what caused the issue in the first place. the "search" method can be used for drafts or records, however, the method lives inside the record's service. So using record.is_draft
always returns False
.
This PR was automatically marked as stale. |
closes https://github.com/zenodo/ops/issues/340