Spaces:
Sleeping
Sleeping
File size: 577 Bytes
adb0416 3777786 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from datetime import datetime, timedelta, timezone
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)
|