Fix voor langer dan een dag geen quota bijschrijven

timedelta.seconds werkte niet zoals ik had verwacht.
This commit is contained in:
2024-08-05 22:28:36 +02:00
parent 8c9d97c317
commit dc1853d1a7
+3 -3
View File
@@ -43,11 +43,11 @@ class Profile(models.Model):
def update_quota(self):
elapsed = timezone.now() - self.quota_last_updated
if elapsed.seconds > 300:
if elapsed.total_seconds() > 300:
noms_per_second = NOMINATIONS_PER_DAY/(60*60*24)
self.quota += noms_per_second * elapsed.seconds
self.quota += noms_per_second * elapsed.total_seconds()
self.quota = min(self.quota, MAX_QUOTA)
print(f"Er zijn {elapsed.seconds}s voorbij, je nieuwe quota is {self.quota}")
print(f"{self.user.username}: Er zijn {elapsed.total_seconds()}s voorbij, je nieuwe quota is {self.quota}")
self.quota_last_updated = timezone.now()
@property