소스 검색

[boardgames] Send notifications on chess imports

Colin Powell 3 달 전
부모
커밋
25900a9911
1개의 변경된 파일6개의 추가작업 그리고 7개의 파일을 삭제
  1. 6 7
      vrobbler/apps/boardgames/sources/lichess.py

+ 6 - 7
vrobbler/apps/boardgames/sources/lichess.py

@@ -1,9 +1,9 @@
 import berserk
-from django.conf import settings
-
 from boardgames.models import BoardGame
-from scrobbles.models import Scrobble
+from django.conf import settings
 from django.contrib.auth import get_user_model
+from scrobbles.models import Scrobble
+from scrobbles.utils import send_notifications_for_scrobble
 
 User = get_user_model()
 
@@ -40,9 +40,6 @@ def import_chess_games_for_all_users():
                 "players": [],
             }
 
-            chess_status = game_dict.get("status")
-            chess_source = game_dict.get("source")
-
             winner = game_dict.get("winner")
             black_player = game_dict.get("players", {}).get("black", {})
             white_player = game_dict.get("players", {}).get("white", {})
@@ -117,5 +114,7 @@ def import_chess_games_for_all_users():
             scrobbles_to_create.append(Scrobble(**scrobble_dict))
 
     if scrobbles_to_create:
-        Scrobble.objects.bulk_create(scrobbles_to_create)
+        created = Scrobble.objects.bulk_create(scrobbles_to_create)
+        for scrobble in created:
+            send_notifications_for_scrobble(scrobble.id)
     return scrobbles_to_create