Merge remote-tracking branch 'origin/api-v1.8.0' into dev
This commit is contained in:
commit
446a732052
8 changed files with 23 additions and 20 deletions
|
|
@ -27,7 +27,7 @@ def __get_default_integration(user_id):
|
|||
current_integrations["jira"] else None
|
||||
|
||||
|
||||
def get_integration(tenant_id, user_id, tool=None):
|
||||
def get_integration(tenant_id, user_id, tool=None, for_delete=False):
|
||||
if tool is None:
|
||||
tool = __get_default_integration(user_id=user_id)
|
||||
if tool is None:
|
||||
|
|
@ -37,7 +37,7 @@ def get_integration(tenant_id, user_id, tool=None):
|
|||
return {"errors": [f"issue tracking tool not supported yet, available: {SUPPORTED_TOOLS}"]}, None
|
||||
if tool == integration_jira_cloud.PROVIDER:
|
||||
integration = integration_jira_cloud.JIRAIntegration(tenant_id=tenant_id, user_id=user_id)
|
||||
if integration.integration is not None and not integration.integration.get("valid", True):
|
||||
if not for_delete and integration.integration is not None and not integration.integration.get("valid", True):
|
||||
return {"errors": ["JIRA: connexion issue/unauthorized"]}, integration
|
||||
return None, integration
|
||||
elif tool == integration_github.PROVIDER:
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ def _isUndefined_operator(op: schemas.SearchEventOperator):
|
|||
def search_sessions(data: schemas.SessionsSearchPayloadSchema, project_id, user_id, errors_only=False,
|
||||
error_status=schemas.ErrorStatus.all, count_only=False, issue=None):
|
||||
if data.bookmarked:
|
||||
data.startDate,data.endDate = sessions_favorite.get_start_end_timestamp(project_id,user_id)
|
||||
data.startDate, data.endDate = sessions_favorite.get_start_end_timestamp(project_id, user_id)
|
||||
|
||||
full_args, query_part = search_query_parts(data=data, error_status=error_status, errors_only=errors_only,
|
||||
favorite_only=data.bookmarked, issue=issue, project_id=project_id,
|
||||
|
|
@ -523,12 +523,12 @@ def search_query_parts(data, error_status, errors_only, favorite_only, issue, pr
|
|||
ss_constraints.append("ms.duration <= %(maxDuration)s")
|
||||
full_args["maxDuration"] = f.value[1]
|
||||
elif filter_type == schemas.FilterType.referrer:
|
||||
extra_from += f"INNER JOIN {events.event_type.LOCATION.table} AS p USING(session_id)"
|
||||
# extra_from += f"INNER JOIN {events.event_type.LOCATION.table} AS p USING(session_id)"
|
||||
if is_any:
|
||||
extra_constraints.append('p.base_referrer IS NOT NULL')
|
||||
extra_constraints.append('s.base_referrer IS NOT NULL')
|
||||
else:
|
||||
extra_constraints.append(
|
||||
_multiple_conditions(f"p.base_referrer {op} %({f_k})s", f.value, is_not=is_not, value_key=f_k))
|
||||
_multiple_conditions(f"s.base_referrer {op} %({f_k})s", f.value, is_not=is_not, value_key=f_k))
|
||||
elif filter_type == events.event_type.METADATA.ui_type:
|
||||
# get metadata list only if you need it
|
||||
if meta_keys is None:
|
||||
|
|
|
|||
|
|
@ -491,7 +491,8 @@ def delete_default_issue_tracking_tool(context: schemas.CurrentContext = Depends
|
|||
def delete_jira_cloud(context: schemas.CurrentContext = Depends(OR_context)):
|
||||
error, integration = integrations_manager.get_integration(tool=integration_jira_cloud.PROVIDER,
|
||||
tenant_id=context.tenant_id,
|
||||
user_id=context.user_id)
|
||||
user_id=context.user_id,
|
||||
for_delete=True)
|
||||
if error is not None:
|
||||
return error
|
||||
return {"data": integration.delete()}
|
||||
|
|
@ -501,7 +502,8 @@ def delete_jira_cloud(context: schemas.CurrentContext = Depends(OR_context)):
|
|||
def delete_github(context: schemas.CurrentContext = Depends(OR_context)):
|
||||
error, integration = integrations_manager.get_integration(tool=integration_github.PROVIDER,
|
||||
tenant_id=context.tenant_id,
|
||||
user_id=context.user_id)
|
||||
user_id=context.user_id,
|
||||
for_delete=True)
|
||||
if error is not None:
|
||||
return error
|
||||
return {"data": integration.delete()}
|
||||
|
|
|
|||
|
|
@ -605,20 +605,16 @@ def search_query_parts_ch(data, error_status, errors_only, favorite_only, issue,
|
|||
ss_constraints.append("ms.duration <= %(maxDuration)s")
|
||||
full_args["maxDuration"] = f.value[1]
|
||||
elif filter_type == schemas.FilterType.referrer:
|
||||
# extra_from += f"INNER JOIN {events.event_type.LOCATION.table} AS p USING(session_id)"
|
||||
if is_any:
|
||||
referrer_constraint = 'isNotNull(r.base_referrer)'
|
||||
extra_constraints.append('isNotNull(s.base_referrer)')
|
||||
ss_constraints.append('isNotNull(ms.base_referrer)')
|
||||
else:
|
||||
referrer_constraint = _multiple_conditions(f"r.base_referrer {op} %({f_k})s", f.value,
|
||||
is_not=is_not, value_key=f_k)
|
||||
referrer_constraint = f"""(SELECT DISTINCT session_id
|
||||
FROM {MAIN_EVENTS_TABLE} AS r
|
||||
WHERE {" AND ".join([f"r.{b}" for b in __events_where_basic])}
|
||||
AND event_type='{__get_event_type(schemas.EventType.location)}'
|
||||
AND {referrer_constraint})"""
|
||||
# events_conditions_where.append(f"""main.session_id IN {referrer_constraint}""")
|
||||
# extra_constraints.append(f"""s.session_id IN {referrer_constraint}""")
|
||||
extra_from += f"\nINNER JOIN {referrer_constraint} AS referred ON(referred.session_id=s.session_id)"
|
||||
extra_constraints.append(
|
||||
_multiple_conditions(f"s.base_referrer {op} toString(%({f_k})s)", f.value, is_not=is_not,
|
||||
value_key=f_k))
|
||||
ss_constraints.append(
|
||||
_multiple_conditions(f"ms.base_referrer {op} toString(%({f_k})s)", f.value, is_not=is_not,
|
||||
value_key=f_k))
|
||||
elif filter_type == events.event_type.METADATA.ui_type:
|
||||
# get metadata list only if you need it
|
||||
if meta_keys is None:
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ ALTER TABLE IF EXISTS alerts
|
|||
ALTER TABLE IF EXISTS sessions
|
||||
ADD COLUMN IF NOT EXISTS referrer text NULL DEFAULT NULL,
|
||||
ADD COLUMN IF NOT EXISTS base_referrer text NULL DEFAULT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_base_referrer_gin_idx ON public.sessions USING GIN (base_referrer gin_trgm_ops);
|
||||
|
||||
ALTER TABLE IF EXISTS events.performance
|
||||
ADD COLUMN IF NOT EXISTS host text NULL DEFAULT NULL,
|
||||
|
|
|
|||
|
|
@ -604,6 +604,7 @@ $$
|
|||
CREATE INDEX IF NOT EXISTS sessions_utm_source_gin_idx ON public.sessions USING GIN (utm_source gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS sessions_utm_medium_gin_idx ON public.sessions USING GIN (utm_medium gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS sessions_utm_campaign_gin_idx ON public.sessions USING GIN (utm_campaign gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS sessions_base_referrer_gin_idx ON public.sessions USING GIN (base_referrer gin_trgm_ops);
|
||||
BEGIN
|
||||
ALTER TABLE public.sessions
|
||||
ADD CONSTRAINT web_browser_constraint CHECK (
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ ALTER TABLE IF EXISTS alerts
|
|||
ALTER TABLE IF EXISTS sessions
|
||||
ADD COLUMN IF NOT EXISTS referrer text NULL DEFAULT NULL,
|
||||
ADD COLUMN IF NOT EXISTS base_referrer text NULL DEFAULT NULL;
|
||||
CREATE INDEX IF NOT EXISTS sessions_base_referrer_gin_idx ON public.sessions USING GIN (base_referrer gin_trgm_ops);
|
||||
|
||||
ALTER TABLE IF EXISTS events.performance
|
||||
ADD COLUMN IF NOT EXISTS host text NULL DEFAULT NULL,
|
||||
|
|
|
|||
|
|
@ -498,6 +498,8 @@ $$
|
|||
CREATE INDEX sessions_utm_source_gin_idx ON public.sessions USING GIN (utm_source gin_trgm_ops);
|
||||
CREATE INDEX sessions_utm_medium_gin_idx ON public.sessions USING GIN (utm_medium gin_trgm_ops);
|
||||
CREATE INDEX sessions_utm_campaign_gin_idx ON public.sessions USING GIN (utm_campaign gin_trgm_ops);
|
||||
CREATE INDEX sessions_base_referrer_gin_idx ON public.sessions USING GIN (base_referrer gin_trgm_ops);
|
||||
|
||||
|
||||
ALTER TABLE public.sessions
|
||||
ADD CONSTRAINT web_browser_constraint CHECK (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue