Dev (#2914)
* feat(chalice): autocomplete return top 10 with stats * fix(chalice): fixed autocomplete top 10 meta-filters * fix(chalice): fixed get recording status
This commit is contained in:
parent
c9d63d912f
commit
70bae502d3
2 changed files with 4 additions and 29 deletions
|
|
@ -11,6 +11,7 @@ from chalicelib.utils import sql_helper as sh
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def search2_series(data: schemas.SessionsSearchPayloadSchema, project_id: int, density: int,
|
def search2_series(data: schemas.SessionsSearchPayloadSchema, project_id: int, density: int,
|
||||||
metric_type: schemas.MetricType, metric_of: schemas.MetricOfTimeseries | schemas.MetricOfTable,
|
metric_type: schemas.MetricType, metric_of: schemas.MetricOfTimeseries | schemas.MetricOfTable,
|
||||||
metric_value: List):
|
metric_value: List):
|
||||||
|
|
@ -1307,7 +1308,6 @@ def search_query_parts_ch(data: schemas.SessionsSearchPayloadSchema, error_statu
|
||||||
return full_args, query_part
|
return full_args, query_part
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_user_sessions(project_id, user_id, start_date, end_date):
|
def get_user_sessions(project_id, user_id, start_date, end_date):
|
||||||
with pg_client.PostgresClient() as cur:
|
with pg_client.PostgresClient() as cur:
|
||||||
constraints = ["s.project_id = %(projectId)s", "s.user_id = %(userId)s"]
|
constraints = ["s.project_id = %(projectId)s", "s.user_id = %(userId)s"]
|
||||||
|
|
@ -1385,29 +1385,4 @@ def session_exists(project_id, session_id):
|
||||||
|
|
||||||
# TODO: support this for CH
|
# TODO: support this for CH
|
||||||
def check_recording_status(project_id: int) -> dict:
|
def check_recording_status(project_id: int) -> dict:
|
||||||
query = f"""
|
return sessions_legacy.check_recording_status(project_id=project_id)
|
||||||
WITH project_sessions AS (SELECT COUNT(1) AS full_count,
|
|
||||||
COUNT(1) FILTER ( WHERE duration IS NOT NULL) AS nn_duration_count
|
|
||||||
FROM public.sessions
|
|
||||||
WHERE project_id = %(project_id)s
|
|
||||||
AND start_ts >= (extract(EPOCH FROM now() - INTERVAL '1 day')) * 1000
|
|
||||||
AND start_ts <= (extract(EPOCH FROM now() + INTERVAL '1 day')) * 1000)
|
|
||||||
SELECT CASE
|
|
||||||
WHEN full_count = 0 THEN 0
|
|
||||||
WHEN nn_duration_count = 0 THEN 1
|
|
||||||
ELSE 2
|
|
||||||
END AS recording_status,
|
|
||||||
full_count AS sessions_count
|
|
||||||
FROM project_sessions;
|
|
||||||
"""
|
|
||||||
|
|
||||||
with pg_client.PostgresClient() as cur:
|
|
||||||
query = cur.mogrify(query, {"project_id": project_id})
|
|
||||||
cur.execute(query)
|
|
||||||
row = cur.fetchone()
|
|
||||||
|
|
||||||
return {
|
|
||||||
"recordingStatus": row["recording_status"],
|
|
||||||
"sessionsCount": row["sessions_count"]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from decouple import config
|
||||||
from fastapi import Depends, Body, BackgroundTasks
|
from fastapi import Depends, Body, BackgroundTasks
|
||||||
|
|
||||||
import schemas
|
import schemas
|
||||||
from chalicelib.core import sourcemaps, events, projects, issues, metadata, reset_password, log_tools, sessions, \
|
from chalicelib.core import sourcemaps, events, projects, issues, metadata, reset_password, log_tools, \
|
||||||
announcements, weekly_report, assist, mobile, tenants, boarding, notifications, webhook, users, saved_search, tags
|
announcements, weekly_report, assist, mobile, tenants, boarding, notifications, webhook, users, saved_search, tags
|
||||||
from chalicelib.core.metrics import custom_metrics
|
from chalicelib.core.metrics import custom_metrics
|
||||||
from chalicelib.core.alerts import alerts
|
from chalicelib.core.alerts import alerts
|
||||||
|
|
@ -13,7 +13,7 @@ from chalicelib.core.issue_tracking import github, integrations_global, integrat
|
||||||
jira_cloud
|
jira_cloud
|
||||||
from chalicelib.core.log_tools import datadog, newrelic, stackdriver, elasticsearch, \
|
from chalicelib.core.log_tools import datadog, newrelic, stackdriver, elasticsearch, \
|
||||||
sentry, bugsnag, cloudwatch, sumologic, rollbar
|
sentry, bugsnag, cloudwatch, sumologic, rollbar
|
||||||
from chalicelib.core.sessions import sessions_assignments
|
from chalicelib.core.sessions import sessions_assignments, sessions
|
||||||
from chalicelib.core.collaborations.collaboration_msteams import MSTeams
|
from chalicelib.core.collaborations.collaboration_msteams import MSTeams
|
||||||
from chalicelib.core.collaborations.collaboration_slack import Slack
|
from chalicelib.core.collaborations.collaboration_slack import Slack
|
||||||
from or_dependencies import OR_context, OR_role
|
from or_dependencies import OR_context, OR_role
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue