瀏覽代碼

Default to getting a boardgame in the DB

Colin Powell 1 年之前
父節點
當前提交
c3ddd01a6f
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      vrobbler/apps/boardgames/models.py

+ 3 - 3
vrobbler/apps/boardgames/models.py

@@ -151,12 +151,12 @@ class BoardGame(ScrobblableMixin):
         cls, lookup_id: str, data: Optional[dict] = {}
     ) -> Optional["BoardGame"]:
         """Given a Lookup ID (either BGG or BGA ID), return a board game object"""
-        boardgame = None
+        boardgame = cls.objects.filter(bggeek_id=lookup_id).first()
 
-        if not data:
+        if not data or not boardgame:
             data = lookup_boardgame_from_bgg(lookup_id)
 
-        if data:
+        if data and not boardgame:
             boardgame, created = cls.objects.get_or_create(
                 title=data["title"], bggeek_id=lookup_id
             )