refactor(chalice): refactored issues
refactor(chalice): support issues in CH
This commit is contained in:
parent
06ff696141
commit
1bb8f3a7b3
7 changed files with 48 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ from functools import cache
|
|||
from typing import Optional
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import issues
|
||||
from chalicelib.core.issues import issues
|
||||
from chalicelib.core.autocomplete import autocomplete
|
||||
from chalicelib.core.sessions import sessions_metas
|
||||
from chalicelib.utils import pg_client, helper
|
||||
|
|
|
|||
11
api/chalicelib/core/issues/__init__.py
Normal file
11
api/chalicelib/core/issues/__init__.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import logging
|
||||
|
||||
from decouple import config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if config("EXP_EVENTS", cast=bool, default=False):
|
||||
logger.info(">>> Using experimental issues")
|
||||
from . import issues_ch as issues
|
||||
else:
|
||||
from . import issues_pg as issues
|
||||
31
api/chalicelib/core/issues/issues_ch.py
Normal file
31
api/chalicelib/core/issues/issues_ch.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
from chalicelib.utils import ch_client, helper
|
||||
from .issues_pg import get_all_types
|
||||
|
||||
|
||||
def get(project_id, issue_id):
|
||||
with ch_client.ClickHouseClient() as cur:
|
||||
query = cur.format(query=""" \
|
||||
SELECT *
|
||||
FROM product_analytics.events
|
||||
WHERE project_id = %(project_id)s
|
||||
AND issue_id = %(issue_id)s;""",
|
||||
parameters={"project_id": project_id, "issue_id": issue_id})
|
||||
data = cur.execute(query=query)
|
||||
if data is not None and len(data) > 0:
|
||||
data = data[0]
|
||||
data["title"] = helper.get_issue_title(data["type"])
|
||||
return helper.dict_to_camel_case(data)
|
||||
|
||||
|
||||
def get_by_session_id(session_id, project_id, issue_type=None):
|
||||
with ch_client.ClickHouseClient as cur:
|
||||
query = cur.format(query=f"""\
|
||||
SELECT *
|
||||
FROM product_analytics.events
|
||||
WHERE session_id = %(session_id)s
|
||||
AND project_id= %(project_id)s
|
||||
{"AND issue_type = %(type)s" if issue_type is not None else ""}
|
||||
ORDER BY created_at;""",
|
||||
parameters={"session_id": session_id, "project_id": project_id, "type": issue_type})
|
||||
data = cur.execute(query)
|
||||
return helper.list_to_camel_case(data)
|
||||
|
|
@ -4,7 +4,7 @@ import logging
|
|||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import issues
|
||||
from chalicelib.core.issues import issues
|
||||
from chalicelib.core.errors import errors
|
||||
from chalicelib.core.metrics import heatmaps, product_analytics, funnels
|
||||
from chalicelib.core.sessions import sessions, sessions_search
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import schemas
|
||||
from chalicelib.core import metadata, issues, assist, canvas, user_testing
|
||||
from chalicelib.core import metadata, assist, canvas, user_testing
|
||||
from chalicelib.core.issues import issues
|
||||
from chalicelib.core.events import events, events_mobile
|
||||
from . import sessions_mobs, sessions_devtool
|
||||
from chalicelib.core.errors.modules import errors_helper
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@ from decouple import config
|
|||
from fastapi import Depends, Body, BackgroundTasks
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import events, projects, issues, metadata, reset_password, log_tools, \
|
||||
from chalicelib.core import events, projects, metadata, reset_password, log_tools, \
|
||||
announcements, weekly_report, assist, mobile, tenants, boarding, notifications, webhook, users, saved_search, tags
|
||||
from chalicelib.core.issues import issues
|
||||
from chalicelib.core.sourcemaps import sourcemaps
|
||||
from chalicelib.core.metrics import custom_metrics
|
||||
from chalicelib.core.alerts import alerts
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue