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.
This commit is contained in:
Daan Sprenkels
2018-11-08 11:13:50 +01:00
parent b2fa50c5a4
commit 5c495b17ef

View File

@ -255,10 +255,10 @@ def upload(request):
# Score function: # Score function:
# - U = duration * songs uploaded # - U = duration * songs uploaded
# - Q = duration * songs queued # - Q = duration * songs queued
# - If 3*U < Q: allow upload (otherwise don't) # - If 2*U < Q: allow upload (otherwise don't)
try: try:
stats = upload_stats(request.user) 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) ratiostr = '{:.2f}'.format(ratio)
except ZeroDivisionError: except ZeroDivisionError:
ratio = 99999.0 # high enough ratio = 99999.0 # high enough
@ -323,12 +323,14 @@ def upload_stats(user):
@transaction.atomic @transaction.atomic
def _request_weight(ps): def _request_weight(ps):
def _is_regular_queue(ps): def _is_regular_queue(ps):
ps = ps.astimezone()
if not ps.played_at: if not ps.played_at:
# Request is from the old times, assume good # Request is from the old times, assume good
return True return True
if not 0 < ps.played_at.weekday() <= 4: if not 0 <= ps.played_at.weekday() <= 4:
return False # Queued in the weekend 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 False # Queued outside of regular opening hours
return True return True