feat(api): sessions-search by issue
This commit is contained in:
parent
54677af4fd
commit
7349e7c560
3 changed files with 38 additions and 5 deletions
|
|
@ -281,6 +281,13 @@ def search2_pg(data: schemas.SessionsSearchPayloadSchema, project_id, user_id, f
|
|||
ss_constraints.append(
|
||||
_multiple_conditions(f"ms.user_device_type {op} %({f_k})s", f.value, is_not=is_not,
|
||||
value_key=f_k))
|
||||
elif filter_type == schemas.FilterType.issue:
|
||||
extra_constraints.append(
|
||||
_multiple_conditions(f"%({f_k})s {op} ANY (s.issue_types)", f.value, is_not=is_not,
|
||||
value_key=f_k))
|
||||
ss_constraints.append(
|
||||
_multiple_conditions(f"%({f_k})s {op} ANY (ms.issue_types)", f.value, is_not=is_not,
|
||||
value_key=f_k))
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
if len(data.events) > 0:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from enum import Enum
|
||||
from typing import Optional, List, Literal, Union
|
||||
|
||||
from pydantic import BaseModel, Field, EmailStr, HttpUrl
|
||||
from pydantic import BaseModel, Field, EmailStr, HttpUrl, root_validator
|
||||
|
||||
from chalicelib.utils.TimeUTC import TimeUTC
|
||||
|
||||
|
|
@ -380,6 +380,7 @@ class FilterType(str, Enum):
|
|||
duration = "DURATION"
|
||||
platform = "PLATFORM"
|
||||
metadata = "METADATA"
|
||||
issue = "ISSUE"
|
||||
|
||||
|
||||
class SearchEventOperator(str, Enum):
|
||||
|
|
@ -406,6 +407,21 @@ class SearchEventOrder(str, Enum):
|
|||
_and = "and"
|
||||
|
||||
|
||||
class IssueType(str, Enum):
|
||||
click_rage = 'click_rage'
|
||||
dead_click = 'dead_click'
|
||||
excessive_scrolling = 'excessive_scrolling'
|
||||
bad_request = 'bad_request'
|
||||
missing_resource = 'missing_resource'
|
||||
memory = 'memory'
|
||||
cpu = 'cpu'
|
||||
slow_resource = 'slow_resource'
|
||||
slow_page_load = 'slow_page_load'
|
||||
crash = 'crash'
|
||||
custom = 'custom'
|
||||
js_exception = 'js_exception'
|
||||
|
||||
|
||||
class _SessionSearchEventSchema(BaseModel):
|
||||
custom: Optional[List[str]] = Field(None)
|
||||
key: Optional[str] = Field(None)
|
||||
|
|
@ -418,11 +434,22 @@ class _SessionSearchEventSchema(BaseModel):
|
|||
class _SessionSearchFilterSchema(BaseModel):
|
||||
custom: Optional[List[str]] = Field(None)
|
||||
key: Optional[str] = Field(None)
|
||||
value: Union[Optional[Union[str, int]], Optional[List[Union[str, int]]]] = Field(...)
|
||||
value: Union[Optional[Union[str, int, IssueType, PlatformType]],
|
||||
Optional[List[Union[str, int, IssueType, PlatformType]]]] = Field(...)
|
||||
type: FilterType = Field(...)
|
||||
operator: SearchEventOperator = Field(...)
|
||||
source: Optional[ErrorSource] = Field(default=ErrorSource.js_exception)
|
||||
|
||||
@root_validator
|
||||
def check_card_number_omitted(cls, values):
|
||||
if values.get("type") == FilterType.issue:
|
||||
for v in values.get("value"):
|
||||
assert IssueType(v)
|
||||
elif values.get("type") == FilterType.platform:
|
||||
for v in values.get("value"):
|
||||
assert PlatformType(v)
|
||||
return values
|
||||
|
||||
|
||||
class SessionsSearchPayloadSchema(BaseModel):
|
||||
events: List[_SessionSearchEventSchema] = Field([])
|
||||
|
|
@ -439,10 +466,12 @@ class SessionsSearchPayloadSchema(BaseModel):
|
|||
class Config:
|
||||
alias_generator = attribute_to_camel_case
|
||||
|
||||
|
||||
class SessionsSearchCountSchema(SessionsSearchPayloadSchema):
|
||||
sort: Optional[str] = Field(default=None)
|
||||
order: Optional[str] = Field(default=None)
|
||||
|
||||
|
||||
class FunnelSearchPayloadSchema(SessionsSearchPayloadSchema):
|
||||
range_value: Optional[str] = Field(None)
|
||||
sort: Optional[str] = Field(None)
|
||||
|
|
|
|||
|
|
@ -523,8 +523,6 @@ $$
|
|||
metadata_8 text DEFAULT NULL,
|
||||
metadata_9 text DEFAULT NULL,
|
||||
metadata_10 text DEFAULT NULL
|
||||
-- ,
|
||||
-- rehydration_id integer REFERENCES rehydrations(rehydration_id) ON DELETE SET NULL
|
||||
);
|
||||
CREATE INDEX ON sessions (project_id, start_ts);
|
||||
CREATE INDEX ON sessions (project_id, user_id);
|
||||
|
|
@ -542,7 +540,6 @@ $$
|
|||
CREATE INDEX ON sessions (project_id, metadata_8);
|
||||
CREATE INDEX ON sessions (project_id, metadata_9);
|
||||
CREATE INDEX ON sessions (project_id, metadata_10);
|
||||
-- CREATE INDEX ON sessions (rehydration_id);
|
||||
CREATE INDEX ON sessions (project_id, watchdogs_score DESC);
|
||||
CREATE INDEX platform_idx ON public.sessions (platform);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue