[people] Fix scrobble count on sqlite

This commit is contained in:
2026-03-21 11:37:18 -04:00
parent 5e835595c3
commit 29cd2f8015

View File

@ -30,9 +30,11 @@ class Person(TimeStampedModel):
def update_scrobble_count(self):
from scrobbles.models import Scrobble
count = Scrobble.objects.filter(
user=self.created_by,
log__with_people_ids__contains=self.id,
).count()
count = 0
for scrobble in Scrobble.objects.filter(user=self.created_by):
if scrobble.log and isinstance(scrobble.log, dict):
person_ids = scrobble.log.get("with_people_ids", [])
if self.id in person_ids:
count += 1
self.scrobble_count = count
self.save(update_fields=["scrobble_count"])