* refactor(chalice): upgraded dependencies

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

* feat(chalice): support table-of-browsers showing user-count

* feat(chalice): support table-of-devices showing user-count

* feat(chalice): support table-of-URLs showing user-count

* 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): return notes-count

* fix(chalice): fixed create heatmap with no replay
This commit is contained in:
Kraiem Taha Yassine 2024-07-08 15:16:33 +02:00 committed by GitHub
parent 11068f9394
commit 8fe44d72f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 9 deletions

View file

@ -1,3 +1,4 @@
import logging
from urllib.parse import urljoin
from decouple import config
@ -9,6 +10,8 @@ from chalicelib.utils import pg_client, helper
from chalicelib.utils import sql_helper as sh
from chalicelib.utils.TimeUTC import TimeUTC
logger = logging.getLogger(__name__)
def get_note(tenant_id, project_id, user_id, note_id, share=None):
with pg_client.PostgresClient() as cur:
@ -66,19 +69,22 @@ def get_all_notes_by_project_id(tenant_id, project_id, user_id, data: schemas.Se
conditions.append("sessions_notes.user_id = %(user_id)s")
else:
conditions.append("(sessions_notes.user_id = %(user_id)s OR sessions_notes.is_public)")
query = cur.mogrify(f"""SELECT sessions_notes.*, users.name AS user_name
query = cur.mogrify(f"""SELECT COUNT(1) OVER () AS full_count, sessions_notes.*, users.name AS user_name
FROM sessions_notes INNER JOIN users USING (user_id)
WHERE {" AND ".join(conditions)}
ORDER BY created_at {data.order}
LIMIT {data.limit} OFFSET {data.limit * (data.page - 1)};""",
{"project_id": project_id, "user_id": user_id, "tenant_id": tenant_id, **extra_params})
logger.debug(query)
cur.execute(query=query)
rows = cur.fetchall()
rows = helper.list_to_camel_case(rows)
result = {"count": 0, "notes": helper.list_to_camel_case(rows)}
if len(rows) > 0:
result["count"] = rows[0]["fullCount"]
for row in rows:
row["createdAt"] = TimeUTC.datetime_to_timestamp(row["createdAt"])
return rows
row.pop("fullCount")
return result
def create(tenant_id, user_id, project_id, session_id, data: schemas.SessionNoteSchema):

View file

@ -347,7 +347,8 @@ else:
logger.warning("--------------------")
raise err
if session:
if len(session) > 0:
session = session[0]
if include_mobs:
session['domURL'] = sessions_mobs.get_urls(session_id=session["session_id"], project_id=project_id)
session['mobsUrl'] = sessions_mobs.get_urls_depercated(session_id=session["session_id"])
@ -361,6 +362,8 @@ else:
session['events'] = events.get_by_session_id(project_id=project_id, session_id=session["session_id"],
event_type=schemas.EventType.location)
else:
return None
return helper.dict_to_camel_case(session)

View file

@ -1,3 +1,4 @@
import logging
from urllib.parse import urljoin
from decouple import config
@ -9,6 +10,8 @@ from chalicelib.utils import pg_client, helper
from chalicelib.utils import sql_helper as sh
from chalicelib.utils.TimeUTC import TimeUTC
logger = logging.getLogger(__name__)
def get_note(tenant_id, project_id, user_id, note_id, share=None):
with pg_client.PostgresClient() as cur:
@ -68,19 +71,22 @@ def get_all_notes_by_project_id(tenant_id, project_id, user_id, data: schemas.Se
else:
conditions.append(
"(sessions_notes.user_id = %(user_id)s OR sessions_notes.is_public AND users.tenant_id = %(tenant_id)s)")
query = cur.mogrify(f"""SELECT sessions_notes.*, users.name AS user_name
query = cur.mogrify(f"""SELECT COUNT(1) OVER () AS full_count, sessions_notes.*, users.name AS user_name
FROM sessions_notes INNER JOIN users USING (user_id)
WHERE {" AND ".join(conditions)}
ORDER BY created_at {data.order}
LIMIT {data.limit} OFFSET {data.limit * (data.page - 1)};""",
{"project_id": project_id, "user_id": user_id, "tenant_id": tenant_id, **extra_params})
logger.debug(query)
cur.execute(query=query)
rows = cur.fetchall()
rows = helper.list_to_camel_case(rows)
result = {"count": 0, "notes": helper.list_to_camel_case(rows)}
if len(rows) > 0:
result["count"] = rows[0]["fullCount"]
for row in rows:
row["createdAt"] = TimeUTC.datetime_to_timestamp(row["createdAt"])
return rows
row.pop("fullCount")
return result
def create(tenant_id, user_id, project_id, session_id, data: schemas.SessionNoteSchema):