feat(chalice): fixed create clickMap card
feat(chalice): cross-legacy sessions support
This commit is contained in:
parent
5c142a8a68
commit
bfcf87a3dd
4 changed files with 8 additions and 6 deletions
|
|
@ -0,0 +1 @@
|
|||
from . import sessions as sessions_legacy
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import schemas
|
||||
from chalicelib.core import sessions_mobs, sessions as sessions_search, events
|
||||
from chalicelib.core import sessions_mobs, sessions_legacy as sessions_search, events
|
||||
from chalicelib.utils import pg_client, helper
|
||||
|
||||
SESSION_PROJECTION_COLS = """s.project_id,
|
||||
|
|
@ -27,7 +27,7 @@ COALESCE((SELECT TRUE
|
|||
AND fs.user_id = %(userId)s LIMIT 1), FALSE) AS viewed """
|
||||
|
||||
|
||||
def search_short_session(data: schemas.FlatClickMapSessionsSearch, project_id, user_id, include_mobs:bool=True):
|
||||
def search_short_session(data: schemas.FlatClickMapSessionsSearch, project_id, user_id, include_mobs: bool = True):
|
||||
no_platform = True
|
||||
for f in data.filters:
|
||||
if f.type == schemas.FilterType.platform:
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ import logging
|
|||
|
||||
logging.basicConfig(level=config("LOGLEVEL", default=logging.INFO))
|
||||
|
||||
from . import sessions as sessions_legacy
|
||||
|
||||
if config("EXP_SESSIONS_SEARCH", cast=bool, default=False):
|
||||
print(">>> Using experimental sessions search")
|
||||
from . import sessions as sessions_legacy
|
||||
from . import sessions_exp as sessions
|
||||
else:
|
||||
from . import sessions as sessions
|
||||
|
|
|
|||
|
|
@ -118,13 +118,14 @@ def __is_click_map(data: schemas_ee.CreateCardSchema):
|
|||
return data.metric_type == schemas.MetricType.click_map
|
||||
|
||||
|
||||
def __get_click_map_chart(project_id, user_id, data: schemas_ee.CreateCardSchema):
|
||||
def __get_click_map_chart(project_id, user_id, data: schemas_ee.CreateCardSchema, include_mobs: bool = True):
|
||||
if len(data.series) == 0:
|
||||
return None
|
||||
data.series[0].filter.startDate = data.startTimestamp
|
||||
data.series[0].filter.endDate = data.endTimestamp
|
||||
return click_maps.search_short_session(project_id=project_id, user_id=user_id,
|
||||
data=schemas.FlatClickMapSessionsSearch(**data.series[0].filter.dict()))
|
||||
data=schemas.FlatClickMapSessionsSearch(**data.series[0].filter.dict()),
|
||||
include_mobs=include_mobs)
|
||||
|
||||
|
||||
# EE only
|
||||
|
|
@ -279,7 +280,6 @@ def create(project_id, user_id, data: schemas_ee.CreateCardSchema, dashboard=Fal
|
|||
session_data = json.dumps(__get_click_map_chart(project_id=project_id, user_id=user_id,
|
||||
data=data, include_mobs=False))
|
||||
_data = {"session_data": session_data}
|
||||
_data = {}
|
||||
for i, s in enumerate(data.series):
|
||||
for k in s.dict().keys():
|
||||
_data[f"{k}_{i}"] = s.__getattribute__(k)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue