1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/tools/freeloaders.py
2019-12-02 12:23:08 -05:00

30 lines
777 B
Python

from data import model
from data.database import User
from app import billing as stripe
from data.plans import get_plan
def get_private_allowed(customer):
if not customer.stripe_id:
return 0
subscription = stripe.Customer.retrieve(customer.stripe_id).get("subscription", None)
if subscription is None:
return 0
plan = get_plan(subscription.plan.id)
return plan["privateRepos"]
# Find customers who have more private repositories than their plans allow
users = User.select()
usage = [
(user.username, model.user.get_private_repo_count(user.username), get_private_allowed(user))
for user in users
]
for username, used, allowed in usage:
if used > allowed:
print("Violation: %s %s > %s" % (username, used, allowed))