File size: 580 Bytes
3777786 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from datetime import datetime, timezone, timedelta
def user_submission_permission(submission_name, users_to_submission_dates, rate_limit_period):
org_or_user, _ = submission_name.split("/")
if org_or_user not in users_to_submission_dates:
return 0
submission_dates = sorted(users_to_submission_dates[org_or_user])
time_limit = (datetime.now(timezone.utc) - timedelta(days=rate_limit_period)).strftime("%Y-%m-%dT%H:%M:%SZ")
submissions_after_timelimit = [d for d in submission_dates if d > time_limit]
return len(submissions_after_timelimit)
|