From 5c495b17ef9f3bc46cb175096a034b8dcd81bbe7 Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Thu, 8 Nov 2018 11:13:50 +0100 Subject: [PATCH] Fix timezone and change upload limit to (2*) I have had enough. People are complaining, I have upper the upload limit to (2*) instead of (3*). It will be on their heads if the db is fucked up in a couple of years. --- marietje/api/views.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/marietje/api/views.py b/marietje/api/views.py index 04b48c7..5d225bd 100644 --- a/marietje/api/views.py +++ b/marietje/api/views.py @@ -255,10 +255,10 @@ def upload(request): # Score function: # - U = duration * songs uploaded # - Q = duration * songs queued - # - If 3*U < Q: allow upload (otherwise don't) + # - If 2*U < Q: allow upload (otherwise don't) try: stats = upload_stats(request.user) - ratio = stats['queued_score'] / (3.0 * stats['upload_score']) + ratio = stats['queued_score'] / (2.0 * stats['upload_score']) ratiostr = '{:.2f}'.format(ratio) except ZeroDivisionError: ratio = 99999.0 # high enough @@ -323,12 +323,14 @@ def upload_stats(user): @transaction.atomic def _request_weight(ps): def _is_regular_queue(ps): + ps = ps.astimezone() if not ps.played_at: # Request is from the old times, assume good return True - if not 0 < ps.played_at.weekday() <= 4: + if not 0 <= ps.played_at.weekday() <= 4: return False # Queued in the weekend - if not 8 <= ps.played_at.hour <= 21: + if not 7 <= ps.played_at.hour <= 22: + # Because of timezone shit, I allow for an extra hour of leeway return False # Queued outside of regular opening hours return True