[people] Fix scrobble count on sqlite
This commit is contained in:
@ -30,9 +30,11 @@ class Person(TimeStampedModel):
|
|||||||
def update_scrobble_count(self):
|
def update_scrobble_count(self):
|
||||||
from scrobbles.models import Scrobble
|
from scrobbles.models import Scrobble
|
||||||
|
|
||||||
count = Scrobble.objects.filter(
|
count = 0
|
||||||
user=self.created_by,
|
for scrobble in Scrobble.objects.filter(user=self.created_by):
|
||||||
log__with_people_ids__contains=self.id,
|
if scrobble.log and isinstance(scrobble.log, dict):
|
||||||
).count()
|
person_ids = scrobble.log.get("with_people_ids", [])
|
||||||
|
if self.id in person_ids:
|
||||||
|
count += 1
|
||||||
self.scrobble_count = count
|
self.scrobble_count = count
|
||||||
self.save(update_fields=["scrobble_count"])
|
self.save(update_fields=["scrobble_count"])
|
||||||
|
|||||||
Reference in New Issue
Block a user