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

CB-231: Retrieve data from database directly for browse review pages #155

Merged
merged 3 commits into from Sep 3, 2017

Conversation

ferbncode
Copy link
Member

Modifed jinja2 filter for fetching entities by id and added code for retrieving data directly from database for browse review (/review) pages.

Modify jinja2 filter and add code for retrieving data for browse
review pages
entites: List of tuples containing the entity_id and the entity_type.

Returns:
Dictionary containing the entities keyed by their mbid.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also mention what the "entity" in the output actually is? Perhaps describing the output for each type is unnecessary, but at least mentioning what kind of information is expected there and what that depends on might be nice.

release_group_mbids = [entity[0] for entity in filter(lambda entity: entity[1] == 'release_group', entities)]
place_mbids = [entity[0] for entity in filter(lambda entity: entity[1] == 'place', entities)]
event_mbids = [entity[0] for entity in filter(lambda entity: entity[1] == 'event', entities)]
if release_group_mbids:
Copy link
Contributor

Choose a reason for hiding this comment

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

This and other checks below seem redundant. If an empty list is passed we expect an empty output anyway, right?

release_group_mbids,
includes=['artists'],
)
entities_info.update(release_groups)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, you can just chain calls. No need to assign a variable here I think.



def get_multiple_entities(entities):
"""Fetch multiple entities using their mbids.
Copy link
Contributor

Choose a reason for hiding this comment

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

MBIDs

"""Fetch multiple entities using their mbids.

Args:
entites: List of tuples containing the entity_id and the entity_type.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why entity_id and entity_type and not simply entity ID and entity type? It would make sense to, for example, reference dictionary keys exactly by name, but in this case I don't see any point.

entites: List of tuples containing the entity_id and the entity_type.

Returns:
Dictionary containing the basic information related to the entites.
Copy link
Contributor

Choose a reason for hiding this comment

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

entities

from flask import current_app


def mock_get_entity_by_id(id, type='release_group'): # pylint: disable=unused-argument
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is id unused?

Copy link
Member Author

Choose a reason for hiding this comment

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

id was unused as all tests in test_review.py use same entity ID for each type. I have fixed this as there might be other entities which may be tested in future. Thanks for pointing it out.

@gentlecat gentlecat merged commit 03899b5 into metabrainz:master Sep 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants