openreplay/ee/api/chalicelib/core/license.py
2021-10-11 17:57:50 +02:00

26 lines
966 B
Python

from chalicelib.utils.helper import environ
from chalicelib.utils import pg_client
from chalicelib.core import unlock
def get_status(tenant_id):
with pg_client.PostgresClient() as cur:
cur.execute(
cur.mogrify("SELECT * FROM public.tenants WHERE tenant_id=%(tenant_id)s;", {"tenant_id": tenant_id}))
r = cur.fetchone()
license = unlock.get_license()
return {
"hasActivePlan": unlock.is_valid(),
"current": {
"edition": r.get("edition", "").upper(),
"versionNumber": r.get("version_number", ""),
"license": license[0:2] + "*" * (len(license) - 4) + license[-2:],
"expirationDate": unlock.get_expiration_date(),
"teamMember": int(environ.get("numberOfSeats", 0))
},
"count": {
"teamMember": r.get("t_users"),
"projects": r.get("t_projects"),
"capturedSessions": r.get("t_sessions")
}
}