* refactor(chalice): upgraded dependencies

* refactor(chalice): upgraded dependencies
feat(chalice): support heatmaps

* fix(chalice): fixed Math-operators validation
refactor(chalice): search for sessions that have events for heatmaps

* refactor(chalice): search for sessions that have at least 1 location event for heatmaps

* refactor(chalice): upgraded dependencies

* refactor(chalice): upgraded dependencies
feat(chalice): support heatmaps

* fix(chalice): fixed Math-operators validation
refactor(chalice): search for sessions that have events for heatmaps

* refactor(chalice): search for sessions that have at least 1 location event for heatmaps

* refactor(chalice): upgraded dependencies
refactor(crons): upgraded dependencies
refactor(alerts): upgraded dependencies

* feat(chalice): get top 10 values for autocomplete CH

* refactor(chalice): cleaned code
refactor(chalice): upgraded dependencies
refactor(alerts): upgraded dependencies
refactor(crons): upgraded dependencies

* feat(chalice): autocomplete return top 10 with stats

* fix(chalice): fixed autocomplete top 10 meta-filters

* refactor(DB): enhanced top-events caching

* feat(DB): support OR scope
feat(chalice): support OR scope
This commit is contained in:
Kraiem Taha Yassine 2024-08-08 17:41:11 +02:00 committed by GitHub
parent 8c54a74f04
commit ae7ad43afe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 44 additions and 1 deletions

View file

@ -84,6 +84,7 @@ async def create_tenant(data: schemas.UserSignupSchema):
'refreshToken': r.pop('refreshToken'),
'refreshTokenMaxAge': r.pop('refreshTokenMaxAge'),
'data': {
"scope": "full",
"user": r
}
}

View file

@ -7,6 +7,7 @@ psycopg2-binary==2.9.9
psycopg[pool,binary]==3.2.1
elasticsearch==8.14.0
jira==3.8.0
cachetools==5.4.0

View file

@ -0,0 +1,30 @@
from cachetools import cached, TTLCache
import schemas
from chalicelib.utils import helper
from chalicelib.utils import pg_client
cache = TTLCache(maxsize=1, ttl=24 * 60 * 60)
@cached(cache)
def get_scope(tenant_id) -> schemas.ScopeType:
with pg_client.PostgresClient() as cur:
query = cur.mogrify(f"""SELECT scope
FROM public.tenants
WHERE tenant_id=%(tenant_id)s;""",
{"tenant_id": tenant_id})
cur.execute(query)
return helper.dict_to_camel_case(cur.fetchone())["scope"]
def update_scope(tenant_id, scope: schemas.ScopeType):
with pg_client.PostgresClient() as cur:
query = cur.mogrify(f"""UPDATE public.tenants
SET scope = %(scope)s
WHERE tenant_id=%(tenant_id)s;""",
{"scope": scope, "tenant_id": tenant_id})
cur.execute(query)
if tenant_id in cache:
cache.pop(tenant_id)
return scope

View file

@ -94,6 +94,7 @@ async def create_tenant(data: schemas.UserSignupSchema):
'refreshToken': r.pop('refreshToken'),
'refreshTokenMaxAge': r.pop('refreshTokenMaxAge'),
'data': {
"scope": "full",
"user": r
}
}

View file

@ -31,7 +31,8 @@ def get_by_tenant_id(tenant_id):
'{license.EDITION}' AS edition,
openreplay_version() AS version_number,
tenants.opt_out,
tenants.tenant_key
tenants.tenant_key,
scope
FROM public.tenants
WHERE tenants.tenant_id = %(tenantId)s
AND tenants.deleted_at ISNULL

View file

@ -7,6 +7,7 @@ psycopg2-binary==2.9.9
psycopg[pool,binary]==3.2.1
elasticsearch==8.14.0
jira==3.8.0
cachetools==5.4.0

View file

@ -11,6 +11,7 @@ from chalicelib.core import sessions, assist, heatmaps, sessions_favorite, sessi
from chalicelib.core import sessions_viewed
from chalicelib.core import tenants, users, projects, license
from chalicelib.core import webhook
from chalicelib.core import scope
from chalicelib.core.collaboration_slack import Slack
from chalicelib.core.users import get_user_settings
from chalicelib.utils import SAML2_helper, smtp
@ -78,6 +79,7 @@ def login_user(response: JSONResponse, spot: Optional[bool] = False, data: schem
content = {
'jwt': r.pop('jwt'),
'data': {
"scope":scope.get_scope(r["tenantId"]),
"user": r
}
}
@ -138,6 +140,11 @@ def get_account(context: schemas.CurrentContext = Depends(OR_context)):
def edit_account(data: schemas.EditAccountSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return users.edit_account(tenant_id=context.tenant_id, user_id=context.user_id, changes=data)
@app.post('/account/scope', tags=["account"])
def change_scope(data: schemas.ScopeSchema = Body(),
context: schemas.CurrentContext = Depends(OR_context)):
data = scope.update_scope(tenant_id=-1, scope=data.scope)
return {'data': data}
@app.post('/integrations/slack', tags=['integrations'])

View file

@ -55,6 +55,7 @@ up to date with every new library you use.
| sqlalchemy | MIT | Python |
| pandas-redshift | MIT | Python |
| confluent-kafka | Apache2 | Python |
| cachetools | MIT | Python |
| amplitude-js | MIT | JavaScript |
| classnames | MIT | JavaScript |
| codemirror | MIT | JavaScript |