Skip to content

Commit

Permalink
Add wrapper for fetch_multiple_places for a single MBID
Browse files Browse the repository at this point in the history
  • Loading branch information
ferbncode authored and gentlecat committed Aug 11, 2017
1 parent 0c7e647 commit 3109872
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions critiquebrainz/frontend/external/musicbrainz_db/place.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ def get_place_by_id(mbid):
key = cache.gen_key(mbid)
place = cache.get(key)
if not place:
place = fetch_multiple_places(
[mbid],
includes=['artist-rels', 'place-rels', 'release-group-rels', 'url-rels'],
)[mbid]
place = _get_place_by_id(mbid)
cache.set(key=key, val=place, time=DEFAULT_CACHE_EXPIRATION)
return place_rel.process(place)


def _get_place_by_id(mbid):
return fetch_multiple_places(
[mbid],
includes=['artist-rels', 'place-rels', 'release-group-rels', 'url-rels'],
).get(mbid)


def fetch_multiple_places(mbids, *, includes=None):
"""Get info related to multiple places using their MusicBrainz IDs.
Expand Down

0 comments on commit 3109872

Please sign in to comment.