[people] Fix scrobble count on sqlite
This commit is contained in:
@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user