mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 22:52:23 +01:00
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:
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user