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

Add eitem_type field to EItem and 'MULTIMEDIA' to DOCUMENT_TYPES #1207

Merged
merged 5 commits into from
May 13, 2024

Conversation

sakshamarora1
Copy link
Contributor

❤️ Thank you for your contribution!

Description

closes: CERNDocumentServer/cds-ils#805
closes: CERNDocumentServer/cds-ils#865

  *  documents: Add MULTIMEDIA to DOCUMENT_TYPES
@sakshamarora1 sakshamarora1 self-assigned this Apr 10, 2024
@@ -829,6 +829,7 @@ def _(x):
eitems=dict(
aggs=dict(
access=dict(terms=dict(field="open_access")),
eitemtype=dict(terms=dict(field="eitem_type")),
Copy link
Contributor

Choose a reason for hiding this comment

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

for naming consistency:

Suggested change
eitemtype=dict(terms=dict(field="eitem_type")),
eitem_type=dict(terms=dict(field="eitem_type")),

@@ -841,6 +842,7 @@ def _(x):
),
),
post_filters=dict(
eitemtype=terms_filter("eitem_type"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
eitemtype=terms_filter("eitem_type"),
eitem_type=terms_filter("eitem_type"),

@@ -57,6 +57,12 @@ def validate(self, record, **kwargs):
class EItem(IlsRecord):
"""EItem record class."""

EITEM_TYPES = [
Copy link
Contributor

Choose a reason for hiding this comment

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

not a strong opinion, I would like to also check with the others (could you discuss on a standup?): would it be more flexible to store these types in a vocabulary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will discuss
But wouldn't keeping the type of the record in its class provide better visibility and readability and also be easier to maintain
if we make it a vocabulary, then we would also need do the same for all other record types, and that will require checking if there might be some other flow that'll be affected by this change

mediums.append("E-BOOK")
eitems = eitem_search.search_by_document_pid(document_pid)
for type in EItem.EITEM_TYPES:
type_count = eitems.filter("term", eitem_type=type).count()
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you check if eitems is immutable? When you use .filter, does it change the eitems object or simply return a new version with the filter applied?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it returns a new version of the object with the filter applied on it, it doesn't apply it in-place

@@ -61,6 +61,9 @@
"document_pid": {
"type": "keyword"
},
"eitem_type": {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need the prefix eitem_, given that we are already in the e-item?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My reasoning for the prefix eitem_ was to be consistent with naming like document_type for documents. Wouldn't it be confusing with just type?

@kpsherva kpsherva merged commit 264a0a7 into inveniosoftware:master May 13, 2024
10 checks passed
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.

Importer: import audiobooks New Audiobooks and Videos document types
3 participants