From 8be8678ca4feeae59da237b7f37a238d13c981c1 Mon Sep 17 00:00:00 2001 From: Zach Waterfield Date: Thu, 21 Nov 2024 15:11:31 -0800 Subject: [PATCH 1/9] Revert "revert: rbac middleware (#26159) (#26343)" This reverts commit b49e0242c0d6252acecc6326782590e65f577557. --- ee/api/rbac/access_control.py | 194 + ee/api/rbac/role.py | 25 +- ee/api/rbac/test/test_access_control.py | 598 ++ .../__snapshots__/test_instance_settings.ambr | 6 - .../test_organization_resource_access.ambr | 14 - ee/api/test/test_action.py | 3 +- ee/api/test/test_organization.py | 6 +- ee/api/test/test_project.py | 2 +- ee/api/test/test_team.py | 2 +- .../views/test/test_clickhouse_experiments.py | 6 +- posthog/api/dashboards/dashboard.py | 8 +- posthog/api/documentation.py | 2 +- posthog/api/feature_flag.py | 13 +- posthog/api/insight.py | 7 +- posthog/api/notebook.py | 8 +- posthog/api/organization.py | 21 +- posthog/api/organization_member.py | 3 +- posthog/api/project.py | 3 +- posthog/api/routing.py | 62 +- posthog/api/search.py | 3 + posthog/api/team.py | 15 +- .../api/test/__snapshots__/test_action.ambr | 526 +- .../test/__snapshots__/test_annotation.ambr | 492 +- .../api/test/__snapshots__/test_api_docs.ambr | 1 - .../api/test/__snapshots__/test_decide.ambr | 625 +- .../api/test/__snapshots__/test_element.ambr | 88 +- .../test/__snapshots__/test_feature_flag.ambr | 236 +- .../api/test/__snapshots__/test_insight.ambr | 568 +- .../test_organization_feature_flag.ambr | 82 +- .../api/test/__snapshots__/test_plugin.ambr | 418 +- .../__snapshots__/test_dashboard.ambr | 5934 ++++++++++------- posthog/api/test/dashboards/test_dashboard.py | 15 +- .../__snapshots__/test_notebook.ambr | 773 ++- posthog/api/test/notebooks/test_notebook.py | 1 + posthog/api/test/test_action.py | 8 +- posthog/api/test/test_activity_log.py | 2 +- posthog/api/test/test_annotation.py | 6 +- posthog/api/test/test_cohort.py | 4 +- posthog/api/test/test_decide.py | 6 +- posthog/api/test/test_event.py | 4 +- posthog/api/test/test_feature_flag.py | 40 +- posthog/api/test/test_insight.py | 10 +- posthog/api/test/test_organization.py | 45 + .../test/test_organization_feature_flag.py | 97 +- posthog/api/test/test_person.py | 4 +- posthog/api/test/test_plugin.py | 8 +- posthog/api/test/test_survey.py | 2 +- posthog/middleware.py | 10 +- posthog/permissions.py | 193 +- posthog/rbac/access_control_api_mixin.py | 13 + posthog/rbac/test/test_user_access_control.py | 559 ++ posthog/rbac/user_access_control.py | 489 ++ .../test_session_recordings.ambr | 3964 ++++++----- posthog/test/test_middleware.py | 8 +- posthog/utils.py | 14 +- .../api/test/test_external_data_source.py | 2 +- 56 files changed, 11103 insertions(+), 5145 deletions(-) create mode 100644 ee/api/rbac/access_control.py create mode 100644 ee/api/rbac/test/test_access_control.py create mode 100644 posthog/rbac/access_control_api_mixin.py create mode 100644 posthog/rbac/test/test_user_access_control.py create mode 100644 posthog/rbac/user_access_control.py diff --git a/ee/api/rbac/access_control.py b/ee/api/rbac/access_control.py new file mode 100644 index 0000000000000..10f8979ec6bea --- /dev/null +++ b/ee/api/rbac/access_control.py @@ -0,0 +1,194 @@ +from typing import TYPE_CHECKING, cast + + +from rest_framework import exceptions, serializers, status +from rest_framework.decorators import action +from rest_framework.request import Request +from rest_framework.response import Response +from rest_framework.viewsets import GenericViewSet + +from ee.models.rbac.access_control import AccessControl +from posthog.models.scopes import API_SCOPE_OBJECTS, APIScopeObjectOrNotSupported +from posthog.models.team.team import Team +from posthog.rbac.user_access_control import ( + ACCESS_CONTROL_LEVELS_RESOURCE, + UserAccessControl, + default_access_level, + highest_access_level, + ordered_access_levels, +) + + +if TYPE_CHECKING: + _GenericViewSet = GenericViewSet +else: + _GenericViewSet = object + + +class AccessControlSerializer(serializers.ModelSerializer): + access_level = serializers.CharField(allow_null=True) + + class Meta: + model = AccessControl + fields = [ + "access_level", + "resource", + "resource_id", + "organization_member", + "role", + "created_by", + "created_at", + "updated_at", + ] + read_only_fields = ["id", "created_at", "created_by"] + + # Validate that resource is a valid option from the API_SCOPE_OBJECTS + def validate_resource(self, resource): + if resource not in API_SCOPE_OBJECTS: + raise serializers.ValidationError("Invalid resource. Must be one of: {}".format(API_SCOPE_OBJECTS)) + + return resource + + # Validate that access control is a valid option + def validate_access_level(self, access_level): + if access_level and access_level not in ordered_access_levels(self.initial_data["resource"]): + raise serializers.ValidationError( + f"Invalid access level. Must be one of: {', '.join(ordered_access_levels(self.initial_data['resource']))}" + ) + + return access_level + + def validate(self, data): + context = self.context + + # Ensure that only one of organization_member or role is set + if data.get("organization_member") and data.get("role"): + raise serializers.ValidationError("You can not scope an access control to both a member and a role.") + + access_control = cast(UserAccessControl, self.context["view"].user_access_control) + resource = data["resource"] + resource_id = data.get("resource_id") + + # We assume the highest level is required for the given resource to edit access controls + required_level = highest_access_level(resource) + team = context["view"].team + the_object = context["view"].get_object() + + if resource_id: + # Check that they have the right access level for this specific resource object + if not access_control.check_can_modify_access_levels_for_object(the_object): + raise exceptions.PermissionDenied(f"Must be {required_level} to modify {resource} permissions.") + else: + # If modifying the base resource rules then we are checking the parent membership (project or organization) + # NOTE: Currently we only support org level in the UI so its simply an org level check + if not access_control.check_can_modify_access_levels_for_object(team): + raise exceptions.PermissionDenied("Must be an Organization admin to modify project-wide permissions.") + + return data + + +class AccessControlViewSetMixin(_GenericViewSet): + """ + Adds an "access_controls" action to the viewset that handles access control for the given resource + + Why a mixin? We want to easily add this to any existing resource, including providing easy helpers for adding access control info such + as the current users access level to any response. + """ + + # 1. Know that the project level access is covered by the Permission check + # 2. Get the actual object which we can pass to the serializer to check if the user created it + # 3. We can also use the serializer to check the access level for the object + + def _get_access_control_serializer(self, *args, **kwargs): + kwargs.setdefault("context", self.get_serializer_context()) + return AccessControlSerializer(*args, **kwargs) + + def _get_access_controls(self, request: Request, is_global=False): + resource = cast(APIScopeObjectOrNotSupported, getattr(self, "scope_object", None)) + user_access_control = cast(UserAccessControl, self.user_access_control) # type: ignore + team = cast(Team, self.team) # type: ignore + + if is_global and resource != "project" or not resource or resource == "INTERNAL": + raise exceptions.NotFound("Role based access controls are only available for projects.") + + obj = self.get_object() + resource_id = obj.id + + if is_global: + # If role based then we are getting all controls for the project that aren't specific to a resource + access_controls = AccessControl.objects.filter(team=team, resource_id=None).all() + else: + # Otherwise we are getting all controls for the specific resource + access_controls = AccessControl.objects.filter(team=team, resource=resource, resource_id=resource_id).all() + + serializer = self._get_access_control_serializer(instance=access_controls, many=True) + user_access_level = user_access_control.access_level_for_object(obj, resource) + + return Response( + { + "access_controls": serializer.data, + # NOTE: For Role based controls we are always configuring resource level items + "available_access_levels": ACCESS_CONTROL_LEVELS_RESOURCE + if is_global + else ordered_access_levels(resource), + "default_access_level": "editor" if is_global else default_access_level(resource), + "user_access_level": user_access_level, + "user_can_edit_access_levels": user_access_control.check_can_modify_access_levels_for_object(obj), + } + ) + + def _update_access_controls(self, request: Request, is_global=False): + resource = getattr(self, "scope_object", None) + obj = self.get_object() + resource_id = str(obj.id) + team = cast(Team, self.team) # type: ignore + + # Generically validate the incoming data + if not is_global: + # If not role based we are deriving from the viewset + data = request.data + data["resource"] = resource + data["resource_id"] = resource_id + + partial_serializer = self._get_access_control_serializer(data=request.data) + partial_serializer.is_valid(raise_exception=True) + params = partial_serializer.validated_data + + instance = AccessControl.objects.filter( + team=team, + resource=params["resource"], + resource_id=params.get("resource_id"), + organization_member=params.get("organization_member"), + role=params.get("role"), + ).first() + + if params["access_level"] is None: + if instance: + instance.delete() + return Response(status=status.HTTP_204_NO_CONTENT) + + # Perform the upsert + if instance: + serializer = self._get_access_control_serializer(instance, data=request.data) + else: + serializer = self._get_access_control_serializer(data=request.data) + + serializer.is_valid(raise_exception=True) + serializer.validated_data["team"] = team + serializer.save() + + return Response(serializer.data, status=status.HTTP_200_OK) + + @action(methods=["GET", "PUT"], detail=True) + def access_controls(self, request: Request, *args, **kwargs): + if request.method == "PUT": + return self._update_access_controls(request) + + return self._get_access_controls(request) + + @action(methods=["GET", "PUT"], detail=True) + def global_access_controls(self, request: Request, *args, **kwargs): + if request.method == "PUT": + return self._update_access_controls(request, is_global=True) + + return self._get_access_controls(request, is_global=True) diff --git a/ee/api/rbac/role.py b/ee/api/rbac/role.py index ccf8acef1f1dc..325ab411c30f6 100644 --- a/ee/api/rbac/role.py +++ b/ee/api/rbac/role.py @@ -4,14 +4,12 @@ from rest_framework import mixins, serializers, viewsets from rest_framework.permissions import SAFE_METHODS, BasePermission -from ee.models.feature_flag_role_access import FeatureFlagRoleAccess from ee.models.rbac.organization_resource_access import OrganizationResourceAccess from ee.models.rbac.role import Role, RoleMembership from posthog.api.organization_member import OrganizationMemberSerializer from posthog.api.routing import TeamAndOrgViewSetMixin from posthog.api.shared import UserBasicSerializer from posthog.models import OrganizationMembership -from posthog.models.feature_flag import FeatureFlag from posthog.models.user import User @@ -38,7 +36,6 @@ def has_permission(self, request, view): class RoleSerializer(serializers.ModelSerializer): created_by = UserBasicSerializer(read_only=True) members = serializers.SerializerMethodField() - associated_flags = serializers.SerializerMethodField() class Meta: model = Role @@ -49,7 +46,6 @@ class Meta: "created_at", "created_by", "members", - "associated_flags", ] read_only_fields = ["id", "created_at", "created_by"] @@ -75,29 +71,12 @@ def get_members(self, role: Role): members = RoleMembership.objects.filter(role=role) return RoleMembershipSerializer(members, many=True).data - def get_associated_flags(self, role: Role): - associated_flags: list[dict] = [] - role_access_objects = FeatureFlagRoleAccess.objects.filter(role=role).values_list("feature_flag_id") - flags = FeatureFlag.objects.filter(id__in=role_access_objects) - for flag in flags: - associated_flags.append({"id": flag.id, "key": flag.key}) - return associated_flags - - -class RoleViewSet( - TeamAndOrgViewSetMixin, - mixins.ListModelMixin, - mixins.CreateModelMixin, - mixins.RetrieveModelMixin, - mixins.UpdateModelMixin, - mixins.DestroyModelMixin, - viewsets.GenericViewSet, -): +class RoleViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet): scope_object = "organization" - permission_classes = [RolePermissions] serializer_class = RoleSerializer queryset = Role.objects.all() + permission_classes = [RolePermissions] def safely_get_queryset(self, queryset): return queryset.filter(**self.request.GET.dict()) diff --git a/ee/api/rbac/test/test_access_control.py b/ee/api/rbac/test/test_access_control.py new file mode 100644 index 0000000000000..4eda789f3448d --- /dev/null +++ b/ee/api/rbac/test/test_access_control.py @@ -0,0 +1,598 @@ +import json +from unittest.mock import MagicMock, patch +from rest_framework import status + +from ee.api.test.base import APILicensedTest +from ee.models.rbac.role import Role, RoleMembership +from posthog.constants import AvailableFeature +from posthog.models.dashboard import Dashboard +from posthog.models.feature_flag.feature_flag import FeatureFlag +from posthog.models.notebook.notebook import Notebook +from posthog.models.organization import OrganizationMembership +from posthog.models.team.team import Team +from posthog.utils import render_template + + +class BaseAccessControlTest(APILicensedTest): + def setUp(self): + super().setUp() + self.organization.available_features = [ + AvailableFeature.PROJECT_BASED_PERMISSIONING, + AvailableFeature.ROLE_BASED_ACCESS, + ] + self.organization.save() + + def _put_project_access_control(self, data=None): + payload = {"access_level": "admin"} + + if data: + payload.update(data) + + return self.client.put( + "/api/projects/@current/access_controls", + payload, + ) + + def _put_global_access_control(self, data=None): + payload = {"access_level": "editor"} + if data: + payload.update(data) + + return self.client.put( + "/api/projects/@current/global_access_controls", + payload, + ) + + def _org_membership(self, level: OrganizationMembership.Level = OrganizationMembership.Level.ADMIN): + self.organization_membership.level = level + self.organization_membership.save() + + +class TestAccessControlProjectLevelAPI(BaseAccessControlTest): + def test_project_change_rejected_if_not_org_admin(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + res = self._put_project_access_control() + assert res.status_code == status.HTTP_403_FORBIDDEN, res.json() + + def test_project_change_accepted_if_org_admin(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + res = self._put_project_access_control() + assert res.status_code == status.HTTP_200_OK, res.json() + + def test_project_change_accepted_if_org_owner(self): + self._org_membership(OrganizationMembership.Level.OWNER) + res = self._put_project_access_control() + assert res.status_code == status.HTTP_200_OK, res.json() + + def test_project_removed_with_null(self): + self._org_membership(OrganizationMembership.Level.OWNER) + res = self._put_project_access_control() + res = self._put_project_access_control({"access_level": None}) + assert res.status_code == status.HTTP_204_NO_CONTENT + + def test_project_change_if_in_access_control(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + # Add ourselves to access + res = self._put_project_access_control( + {"organization_member": str(self.organization_membership.id), "access_level": "admin"} + ) + assert res.status_code == status.HTTP_200_OK, res.json() + + self._org_membership(OrganizationMembership.Level.MEMBER) + + # Now change ourselves to a member + res = self._put_project_access_control( + {"organization_member": str(self.organization_membership.id), "access_level": "member"} + ) + assert res.status_code == status.HTTP_200_OK, res.json() + assert res.json()["access_level"] == "member" + + # Now try and change our own membership and fail! + res = self._put_project_access_control( + {"organization_member": str(self.organization_membership.id), "access_level": "admin"} + ) + assert res.status_code == status.HTTP_403_FORBIDDEN + assert res.json()["detail"] == "Must be admin to modify project permissions." + + def test_project_change_rejected_if_not_in_organization(self): + self.organization_membership.delete() + res = self._put_project_access_control( + {"organization_member": str(self.organization_membership.id), "access_level": "admin"} + ) + assert res.status_code == status.HTTP_404_NOT_FOUND, res.json() + + def test_project_change_rejected_if_bad_access_level(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + res = self._put_project_access_control({"access_level": "bad"}) + assert res.status_code == status.HTTP_400_BAD_REQUEST, res.json() + assert res.json()["detail"] == "Invalid access level. Must be one of: none, member, admin", res.json() + + +class TestAccessControlResourceLevelAPI(BaseAccessControlTest): + def setUp(self): + super().setUp() + + self.notebook = Notebook.objects.create( + team=self.team, created_by=self.user, short_id="0", title="first notebook" + ) + + self.other_user = self._create_user("other_user") + self.other_user_notebook = Notebook.objects.create( + team=self.team, created_by=self.other_user, short_id="1", title="first notebook" + ) + + def _get_access_controls(self): + return self.client.get(f"/api/projects/@current/notebooks/{self.notebook.short_id}/access_controls") + + def _put_access_control(self, data=None, notebook_id=None): + payload = { + "access_level": "editor", + } + + if data: + payload.update(data) + return self.client.put( + f"/api/projects/@current/notebooks/{notebook_id or self.notebook.short_id}/access_controls", + payload, + ) + + def test_get_access_controls(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + res = self._get_access_controls() + assert res.status_code == status.HTTP_200_OK, res.json() + assert res.json() == { + "access_controls": [], + "available_access_levels": ["none", "viewer", "editor"], + "user_access_level": "editor", + "default_access_level": "editor", + "user_can_edit_access_levels": True, + } + + def test_change_rejected_if_not_org_admin(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + res = self._put_access_control(notebook_id=self.other_user_notebook.short_id) + assert res.status_code == status.HTTP_403_FORBIDDEN, res.json() + + def test_change_accepted_if_org_admin(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + res = self._put_access_control(notebook_id=self.other_user_notebook.short_id) + assert res.status_code == status.HTTP_200_OK, res.json() + + def test_change_accepted_if_creator_of_the_resource(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + res = self._put_access_control(notebook_id=self.notebook.short_id) + assert res.status_code == status.HTTP_200_OK, res.json() + + +class TestGlobalAccessControlsPermissions(BaseAccessControlTest): + def setUp(self): + super().setUp() + + self.role = Role.objects.create(name="Engineers", organization=self.organization) + self.role_membership = RoleMembership.objects.create(user=self.user, role=self.role) + + def test_admin_can_always_access(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + assert ( + self._put_global_access_control({"resource": "feature_flag", "access_level": "none"}).status_code + == status.HTTP_200_OK + ) + assert self.client.get("/api/projects/@current/feature_flags").status_code == status.HTTP_200_OK + + def test_forbidden_access_if_resource_wide_control_in_place(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + assert ( + self._put_global_access_control({"resource": "feature_flag", "access_level": "none"}).status_code + == status.HTTP_200_OK + ) + self._org_membership(OrganizationMembership.Level.MEMBER) + + assert self.client.get("/api/projects/@current/feature_flags").status_code == status.HTTP_403_FORBIDDEN + assert self.client.post("/api/projects/@current/feature_flags").status_code == status.HTTP_403_FORBIDDEN + + def test_forbidden_write_access_if_resource_wide_control_in_place(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + assert ( + self._put_global_access_control({"resource": "feature_flag", "access_level": "viewer"}).status_code + == status.HTTP_200_OK + ) + self._org_membership(OrganizationMembership.Level.MEMBER) + + assert self.client.get("/api/projects/@current/feature_flags").status_code == status.HTTP_200_OK + assert self.client.post("/api/projects/@current/feature_flags").status_code == status.HTTP_403_FORBIDDEN + + def test_access_granted_with_granted_role(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + assert ( + self._put_global_access_control({"resource": "feature_flag", "access_level": "none"}).status_code + == status.HTTP_200_OK + ) + assert ( + self._put_global_access_control( + {"resource": "feature_flag", "access_level": "viewer", "role": self.role.id} + ).status_code + == status.HTTP_200_OK + ) + self._org_membership(OrganizationMembership.Level.MEMBER) + + assert self.client.get("/api/projects/@current/feature_flags").status_code == status.HTTP_200_OK + assert self.client.post("/api/projects/@current/feature_flags").status_code == status.HTTP_403_FORBIDDEN + + self.role_membership.delete() + assert self.client.get("/api/projects/@current/feature_flags").status_code == status.HTTP_403_FORBIDDEN + + +class TestAccessControlPermissions(BaseAccessControlTest): + """ + Test actual permissions being applied for a resource (notebooks as an example) + """ + + def setUp(self): + super().setUp() + self.other_user = self._create_user("other_user") + + self.other_user_notebook = Notebook.objects.create( + team=self.team, created_by=self.other_user, title="not my notebook" + ) + + self.notebook = Notebook.objects.create(team=self.team, created_by=self.user, title="my notebook") + + def _post_notebook(self): + return self.client.post("/api/projects/@current/notebooks/", {"title": "notebook"}) + + def _patch_notebook(self, id: str): + return self.client.patch(f"/api/projects/@current/notebooks/{id}", {"title": "new-title"}) + + def _get_notebook(self, id: str): + return self.client.get(f"/api/projects/@current/notebooks/{id}") + + def _put_notebook_access_control(self, notebook_id: str, data=None): + payload = { + "access_level": "editor", + } + + if data: + payload.update(data) + return self.client.put( + f"/api/projects/@current/notebooks/{notebook_id}/access_controls", + payload, + ) + + def test_default_allows_all_access(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + assert self._get_notebook(self.other_user_notebook.short_id).status_code == status.HTTP_200_OK + assert self._patch_notebook(id=self.other_user_notebook.short_id).status_code == status.HTTP_200_OK + res = self._post_notebook() + assert res.status_code == status.HTTP_201_CREATED + assert self._patch_notebook(id=res.json()["short_id"]).status_code == status.HTTP_200_OK + + def test_rejects_all_access_without_project_access(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + assert self._put_project_access_control({"access_level": "none"}).status_code == status.HTTP_200_OK + self._org_membership(OrganizationMembership.Level.MEMBER) + + assert self._get_notebook(self.other_user_notebook.short_id).status_code == status.HTTP_403_FORBIDDEN + assert self._patch_notebook(id=self.other_user_notebook.short_id).status_code == status.HTTP_403_FORBIDDEN + assert self._post_notebook().status_code == status.HTTP_403_FORBIDDEN + + def test_permits_access_with_member_control(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + assert self._put_project_access_control({"access_level": "none"}).status_code == status.HTTP_200_OK + assert ( + self._put_project_access_control( + {"access_level": "member", "organization_member": str(self.organization_membership.id)} + ).status_code + == status.HTTP_200_OK + ) + self._org_membership(OrganizationMembership.Level.MEMBER) + + assert self._get_notebook(self.other_user_notebook.short_id).status_code == status.HTTP_200_OK + assert self._patch_notebook(id=self.other_user_notebook.short_id).status_code == status.HTTP_200_OK + assert self._post_notebook().status_code == status.HTTP_201_CREATED + + def test_rejects_edit_access_with_resource_control(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + # Set other notebook to only allow view access by default + assert ( + self._put_notebook_access_control(self.other_user_notebook.short_id, {"access_level": "viewer"}).status_code + == status.HTTP_200_OK + ) + self._org_membership(OrganizationMembership.Level.MEMBER) + + assert self._get_notebook(self.other_user_notebook.short_id).status_code == status.HTTP_200_OK + assert self._patch_notebook(id=self.other_user_notebook.short_id).status_code == status.HTTP_403_FORBIDDEN + assert self._post_notebook().status_code == status.HTTP_201_CREATED + + def test_rejects_view_access_if_not_creator(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + # Set other notebook to only allow view access by default + assert ( + self._put_notebook_access_control(self.other_user_notebook.short_id, {"access_level": "none"}).status_code + == status.HTTP_200_OK + ) + assert ( + self._put_notebook_access_control(self.notebook.short_id, {"access_level": "none"}).status_code + == status.HTTP_200_OK + ) + self._org_membership(OrganizationMembership.Level.MEMBER) + + # Access to other notebook is denied + assert self._get_notebook(self.other_user_notebook.short_id).status_code == status.HTTP_403_FORBIDDEN + assert self._patch_notebook(id=self.other_user_notebook.short_id).status_code == status.HTTP_403_FORBIDDEN + # As creator, access to my notebook is still permitted + assert self._get_notebook(self.notebook.short_id).status_code == status.HTTP_200_OK + assert self._patch_notebook(id=self.notebook.short_id).status_code == status.HTTP_200_OK + + def test_org_level_endpoints_work(self): + assert self.client.get("/api/organizations/@current/plugins").status_code == status.HTTP_200_OK + + +class TestAccessControlQueryCounts(BaseAccessControlTest): + def setUp(self): + super().setUp() + self.other_user = self._create_user("other_user") + + self.other_user_notebook = Notebook.objects.create( + team=self.team, created_by=self.other_user, title="not my notebook" + ) + + self.notebook = Notebook.objects.create(team=self.team, created_by=self.user, title="my notebook") + + # Baseline call to trigger caching of one off things like instance settings + self.client.get(f"/api/projects/@current/notebooks/{self.notebook.short_id}") + + def test_query_counts(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + my_dashboard = Dashboard.objects.create(team=self.team, created_by=self.user) + other_user_dashboard = Dashboard.objects.create(team=self.team, created_by=self.other_user) + + # Baseline query (triggers any first time cache things) + self.client.get(f"/api/projects/@current/notebooks/{self.notebook.short_id}") + baseline = 11 + + # Access controls total 2 extra queries - 1 for org membership, 1 for the user roles, 1 for the preloaded access controls + with self.assertNumQueries(baseline + 4): + self.client.get(f"/api/projects/@current/dashboards/{my_dashboard.id}?no_items_field=true") + + # Accessing a different users dashboard doesn't +1 as the preload works using the pk + with self.assertNumQueries(baseline + 4): + self.client.get(f"/api/projects/@current/dashboards/{other_user_dashboard.id}?no_items_field=true") + + baseline = 6 + # Getting my own notebook is the same as a dashboard - 2 extra queries + with self.assertNumQueries(baseline + 4): + self.client.get(f"/api/projects/@current/notebooks/{self.notebook.short_id}") + + # Except when accessing a different notebook where we _also_ need to check as we are not the creator and the pk is not the same (short_id) + with self.assertNumQueries(baseline + 5): + self.client.get(f"/api/projects/@current/notebooks/{self.other_user_notebook.short_id}") + + baseline = 4 + # Project access doesn't double query the object + with self.assertNumQueries(baseline + 7): + # We call this endpoint as we don't want to include all the extra queries that rendering the project uses + self.client.get("/api/projects/@current/is_generating_demo_data") + + # When accessing the list of notebooks we have extra queries due to checking for role based access and filtering out items + baseline = 7 + with self.assertNumQueries(baseline + 4): # org, roles, preloaded access controls + self.client.get("/api/projects/@current/notebooks/") + + def test_query_counts_with_preload_optimization(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + my_dashboard = Dashboard.objects.create(team=self.team, created_by=self.user) + other_user_dashboard = Dashboard.objects.create(team=self.team, created_by=self.other_user) + + # Baseline query (triggers any first time cache things) + self.client.get(f"/api/projects/@current/notebooks/{self.notebook.short_id}") + baseline = 11 + + # Access controls total 2 extra queries - 1 for org membership, 1 for the user roles, 1 for the preloaded access controls + with self.assertNumQueries(baseline + 4): + self.client.get(f"/api/projects/@current/dashboards/{my_dashboard.id}?no_items_field=true") + + # Accessing a different users dashboard doesn't +1 as the preload works using the pk + with self.assertNumQueries(baseline + 4): + self.client.get(f"/api/projects/@current/dashboards/{other_user_dashboard.id}?no_items_field=true") + + def test_query_counts_only_adds_1_for_non_pk_resources(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + # Baseline query (triggers any first time cache things) + self.client.get(f"/api/projects/@current/notebooks/{self.notebook.short_id}") + baseline = 11 + + baseline = 6 + # Getting my own notebook is the same as a dashboard - 2 extra queries + with self.assertNumQueries(baseline + 4): + self.client.get(f"/api/projects/@current/notebooks/{self.notebook.short_id}") + + # Except when accessing a different notebook where we _also_ need to check as we are not the creator and the pk is not the same (short_id) + with self.assertNumQueries(baseline + 5): + self.client.get(f"/api/projects/@current/notebooks/{self.other_user_notebook.short_id}") + + def test_query_counts_stable_for_project_access(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + baseline = 4 + # Project access doesn't double query the object + with self.assertNumQueries(baseline + 7): + # We call this endpoint as we don't want to include all the extra queries that rendering the project uses + self.client.get("/api/projects/@current/is_generating_demo_data") + + # When accessing the list of notebooks we have extra queries due to checking for role based access and filtering out items + baseline = 7 + with self.assertNumQueries(baseline + 4): # org, roles, preloaded access controls + self.client.get("/api/projects/@current/notebooks/") + + def test_query_counts_stable_when_listing_resources(self): + # When accessing the list of notebooks we have extra queries due to checking for role based access and filtering out items + baseline = 7 + with self.assertNumQueries(baseline + 4): # org, roles, preloaded access controls + self.client.get("/api/projects/@current/notebooks/") + + def test_query_counts_stable_when_listing_resources_including_access_control_info(self): + for i in range(10): + FeatureFlag.objects.create(team=self.team, created_by=self.other_user, key=f"flag-{i}") + + baseline = 42 # This is a lot! There is currently an n+1 issue with the legacy access control system + with self.assertNumQueries(baseline + 6): # org, roles, preloaded permissions acs, preloaded acs for the list + self.client.get("/api/projects/@current/feature_flags/") + + for i in range(10): + FeatureFlag.objects.create(team=self.team, created_by=self.other_user, key=f"flag-{10 + i}") + + baseline = baseline + (10 * 3) # The existing access control adds 3 queries per item :( + with self.assertNumQueries(baseline + 6): # org, roles, preloaded permissions acs, preloaded acs for the list + self.client.get("/api/projects/@current/feature_flags/") + + +class TestAccessControlFiltering(BaseAccessControlTest): + def setUp(self): + super().setUp() + self.other_user = self._create_user("other_user") + + self.other_user_notebook = Notebook.objects.create( + team=self.team, created_by=self.other_user, title="not my notebook" + ) + + self.notebook = Notebook.objects.create(team=self.team, created_by=self.user, title="my notebook") + + def _put_notebook_access_control(self, notebook_id: str, data=None): + payload = { + "access_level": "editor", + } + + if data: + payload.update(data) + return self.client.put( + f"/api/projects/@current/notebooks/{notebook_id}/access_controls", + payload, + ) + + def _get_notebooks(self): + return self.client.get("/api/projects/@current/notebooks/") + + def test_default_allows_all_access(self): + self._org_membership(OrganizationMembership.Level.MEMBER) + assert len(self._get_notebooks().json()["results"]) == 2 + + def test_does_not_list_notebooks_without_access(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + assert ( + self._put_notebook_access_control(self.other_user_notebook.short_id, {"access_level": "none"}).status_code + == status.HTTP_200_OK + ) + assert ( + self._put_notebook_access_control(self.notebook.short_id, {"access_level": "none"}).status_code + == status.HTTP_200_OK + ) + self._org_membership(OrganizationMembership.Level.MEMBER) + + res = self._get_notebooks() + assert len(res.json()["results"]) == 1 + assert res.json()["results"][0]["id"] == str(self.notebook.id) + + def test_list_notebooks_with_explicit_access(self): + self._org_membership(OrganizationMembership.Level.ADMIN) + assert ( + self._put_notebook_access_control(self.other_user_notebook.short_id, {"access_level": "none"}).status_code + == status.HTTP_200_OK + ) + assert ( + self._put_notebook_access_control( + self.other_user_notebook.short_id, + {"organization_member": str(self.organization_membership.id), "access_level": "viewer"}, + ).status_code + == status.HTTP_200_OK + ) + self._org_membership(OrganizationMembership.Level.MEMBER) + + res = self._get_notebooks() + assert len(res.json()["results"]) == 2 + + def test_search_results_exclude_restricted_objects(self): + res = self.client.get("/api/projects/@current/search?q=my notebook") + assert len(res.json()["results"]) == 2 + + self._org_membership(OrganizationMembership.Level.ADMIN) + assert ( + self._put_notebook_access_control(self.other_user_notebook.short_id, {"access_level": "none"}).status_code + == status.HTTP_200_OK + ) + + self._org_membership(OrganizationMembership.Level.MEMBER) + + res = self.client.get("/api/projects/@current/search?q=my notebook") + assert len(res.json()["results"]) == 1 + + +class TestAccessControlProjectFiltering(BaseAccessControlTest): + """ + Projects are listed in multiple places and ways so we need to test all of them here + """ + + def setUp(self): + super().setUp() + self.other_team = Team.objects.create(organization=self.organization, name="other team") + self.other_team_2 = Team.objects.create(organization=self.organization, name="other team 2") + + def _put_project_access_control_as_admin(self, team_id: int, data=None): + self._org_membership(OrganizationMembership.Level.ADMIN) + payload = { + "access_level": "editor", + } + + if data: + payload.update(data) + res = self.client.put( + f"/api/projects/{team_id}/access_controls", + payload, + ) + + self._org_membership(OrganizationMembership.Level.MEMBER) + + assert res.status_code == status.HTTP_200_OK, res.json() + return res + + def _get_posthog_app_context(self): + mock_template = MagicMock() + with patch("posthog.utils.get_template", return_value=mock_template): + mock_request = MagicMock() + mock_request.user = self.user + mock_request.GET = {} + render_template("index.html", request=mock_request, context={}) + + # Get the context passed to the template + return json.loads(mock_template.render.call_args[0][0]["posthog_app_context"]) + + def test_default_lists_all_projects(self): + assert len(self.client.get("/api/projects").json()["results"]) == 3 + me_response = self.client.get("/api/users/@me").json() + assert len(me_response["organization"]["teams"]) == 3 + + def test_does_not_list_projects_without_access(self): + self._put_project_access_control_as_admin(self.other_team.id, {"access_level": "none"}) + assert len(self.client.get("/api/projects").json()["results"]) == 2 + me_response = self.client.get("/api/users/@me").json() + assert len(me_response["organization"]["teams"]) == 2 + + def test_always_lists_all_projects_if_org_admin(self): + self._put_project_access_control_as_admin(self.other_team.id, {"access_level": "none"}) + self._org_membership(OrganizationMembership.Level.ADMIN) + assert len(self.client.get("/api/projects").json()["results"]) == 3 + me_response = self.client.get("/api/users/@me").json() + assert len(me_response["organization"]["teams"]) == 3 + + def test_template_render_filters_teams(self): + app_context = self._get_posthog_app_context() + assert len(app_context["current_user"]["organization"]["teams"]) == 3 + assert app_context["current_team"]["id"] == self.team.id + assert app_context["current_team"]["user_access_level"] == "admin" + + self._put_project_access_control_as_admin(self.team.id, {"access_level": "none"}) + app_context = self._get_posthog_app_context() + assert len(app_context["current_user"]["organization"]["teams"]) == 2 + assert app_context["current_team"]["id"] == self.team.id + assert app_context["current_team"]["user_access_level"] == "none" + + +# TODO: Add tests to check that a dashboard can't be edited if the user doesn't have access diff --git a/ee/api/test/__snapshots__/test_instance_settings.ambr b/ee/api/test/__snapshots__/test_instance_settings.ambr index 020447634a620..539702c060a9e 100644 --- a/ee/api/test/__snapshots__/test_instance_settings.ambr +++ b/ee/api/test/__snapshots__/test_instance_settings.ambr @@ -5,9 +5,3 @@ ALTER TABLE sharded_performance_events ON CLUSTER 'posthog' MODIFY TTL toDate(timestamp) + toIntervalWeek(5) ''' # --- -# name: TestInstanceSettings.test_update_recordings_ttl_setting - ''' - /* user_id:0 request:_snapshot_ */ - ALTER TABLE sharded_session_recording_events ON CLUSTER 'posthog' MODIFY TTL toDate(created_at) + toIntervalWeek(5) - ''' -# --- diff --git a/ee/api/test/__snapshots__/test_organization_resource_access.ambr b/ee/api/test/__snapshots__/test_organization_resource_access.ambr index b7151ed8b3582..bf8927ee81e66 100644 --- a/ee/api/test/__snapshots__/test_organization_resource_access.ambr +++ b/ee/api/test/__snapshots__/test_organization_resource_access.ambr @@ -101,20 +101,6 @@ LIMIT 100 ''' # --- -# name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.14 - ''' - SELECT "ee_organizationresourceaccess"."id", - "ee_organizationresourceaccess"."resource", - "ee_organizationresourceaccess"."access_level", - "ee_organizationresourceaccess"."organization_id", - "ee_organizationresourceaccess"."created_by_id", - "ee_organizationresourceaccess"."created_at", - "ee_organizationresourceaccess"."updated_at" - FROM "ee_organizationresourceaccess" - WHERE "ee_organizationresourceaccess"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 100 - ''' -# --- # name: TestOrganizationResourceAccessAPI.test_list_organization_resource_access_is_not_nplus1.2 ''' SELECT "posthog_organization"."id", diff --git a/ee/api/test/test_action.py b/ee/api/test/test_action.py index 152089d0c1e1a..1664f6828157a 100644 --- a/ee/api/test/test_action.py +++ b/ee/api/test/test_action.py @@ -79,7 +79,8 @@ def test_actions_does_not_nplus1(self): # django_session + user + team + look up if rate limit is enabled (cached after first lookup) # + organizationmembership + organization + action + taggeditem - with self.assertNumQueries(8): + # + access control queries + with self.assertNumQueries(12): response = self.client.get(f"/api/projects/{self.team.id}/actions") self.assertEqual(response.json()["results"][0]["tags"][0], "tag") self.assertEqual(response.status_code, status.HTTP_200_OK) diff --git a/ee/api/test/test_organization.py b/ee/api/test/test_organization.py index ed47558d1efc4..46b4049df35d9 100644 --- a/ee/api/test/test_organization.py +++ b/ee/api/test/test_organization.py @@ -133,7 +133,9 @@ def test_no_delete_organization_not_owning(self): response.json(), { "attr": None, - "detail": "Your organization access level is insufficient.", + "detail": "You do not have admin access to this resource." + if level == OrganizationMembership.Level.MEMBER + else "Your organization access level is insufficient.", "code": "permission_denied", "type": "authentication_error", }, @@ -196,7 +198,7 @@ def test_update_org(self): expected_response = { "attr": None, - "detail": "Your organization access level is insufficient.", + "detail": "You do not have admin access to this resource.", "code": "permission_denied", "type": "authentication_error", } diff --git a/ee/api/test/test_project.py b/ee/api/test/test_project.py index 1711f4dbaa4ed..3c8880954fa3f 100644 --- a/ee/api/test/test_project.py +++ b/ee/api/test/test_project.py @@ -118,7 +118,7 @@ def test_list_projects_restricted_ones_hidden(self): projects_response = self.client.get(f"/api/environments/") # 9 (above): - with self.assertNumQueries(FuzzyInt(10, 11)): + with self.assertNumQueries(FuzzyInt(13, 14)): current_org_response = self.client.get(f"/api/organizations/{self.organization.id}/") self.assertEqual(projects_response.status_code, 200) diff --git a/ee/api/test/test_team.py b/ee/api/test/test_team.py index 8bed93a3aff1b..dafdd6d9def8a 100644 --- a/ee/api/test/test_team.py +++ b/ee/api/test/test_team.py @@ -621,7 +621,7 @@ def test_list_teams_restricted_ones_hidden(self): projects_response = self.client.get(f"/api/environments/") # 9 (above): - with self.assertNumQueries(FuzzyInt(10, 11)): + with self.assertNumQueries(FuzzyInt(13, 14)): current_org_response = self.client.get(f"/api/organizations/{self.organization.id}/") self.assertEqual(projects_response.status_code, HTTP_200_OK) diff --git a/ee/clickhouse/views/test/test_clickhouse_experiments.py b/ee/clickhouse/views/test/test_clickhouse_experiments.py index 751b65ed082b9..aa6d791c6d3d0 100644 --- a/ee/clickhouse/views/test/test_clickhouse_experiments.py +++ b/ee/clickhouse/views/test/test_clickhouse_experiments.py @@ -57,7 +57,7 @@ def test_getting_experiments_is_not_nplus1(self) -> None: format="json", ).json() - with self.assertNumQueries(FuzzyInt(9, 10)): + with self.assertNumQueries(FuzzyInt(13, 14)): response = self.client.get(f"/api/projects/{self.team.id}/experiments") self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -74,7 +74,7 @@ def test_getting_experiments_is_not_nplus1(self) -> None: format="json", ).json() - with self.assertNumQueries(FuzzyInt(9, 10)): + with self.assertNumQueries(FuzzyInt(13, 14)): response = self.client.get(f"/api/projects/{self.team.id}/experiments") self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1452,7 +1452,7 @@ def test_used_in_experiment_is_populated_correctly_for_feature_flag_list(self) - ).json() # TODO: Make sure permission bool doesn't cause n + 1 - with self.assertNumQueries(12): + with self.assertNumQueries(17): response = self.client.get(f"/api/projects/{self.team.id}/feature_flags") self.assertEqual(response.status_code, status.HTTP_200_OK) result = response.json() diff --git a/posthog/api/dashboards/dashboard.py b/posthog/api/dashboards/dashboard.py index ca626c0d1a8c2..8fbbb98b58404 100644 --- a/posthog/api/dashboards/dashboard.py +++ b/posthog/api/dashboards/dashboard.py @@ -15,6 +15,8 @@ from posthog.api.dashboards.dashboard_template_json_schema_parser import ( DashboardTemplateCreationJSONSchemaParser, ) +from posthog.rbac.access_control_api_mixin import AccessControlViewSetMixin +from posthog.rbac.user_access_control import UserAccessControlSerializerMixin from posthog.api.forbid_destroy_model import ForbidDestroyModel from posthog.api.insight import InsightSerializer, InsightViewSet from posthog.api.monitoring import Feature, monitor @@ -87,6 +89,7 @@ class DashboardBasicSerializer( TaggedItemSerializerMixin, serializers.ModelSerializer, UserPermissionsSerializerMixin, + UserAccessControlSerializerMixin, ): created_by = UserBasicSerializer(read_only=True) effective_privilege_level = serializers.SerializerMethodField() @@ -109,6 +112,7 @@ class Meta: "restriction_level", "effective_restriction_level", "effective_privilege_level", + "user_access_level", ] read_only_fields = fields @@ -157,8 +161,9 @@ class Meta: "restriction_level", "effective_restriction_level", "effective_privilege_level", + "user_access_level", ] - read_only_fields = ["creation_mode", "effective_restriction_level", "is_shared"] + read_only_fields = ["creation_mode", "effective_restriction_level", "is_shared", "user_access_level"] def validate_filters(self, value) -> dict: if not isinstance(value, dict): @@ -450,6 +455,7 @@ def _update_creation_mode(self, validated_data, use_template: str, use_dashboard class DashboardsViewSet( TeamAndOrgViewSetMixin, + AccessControlViewSetMixin, TaggedItemViewSetMixin, ForbidDestroyModel, viewsets.ModelViewSet, diff --git a/posthog/api/documentation.py b/posthog/api/documentation.py index d06dd23a3151e..d885aa12a3c84 100644 --- a/posthog/api/documentation.py +++ b/posthog/api/documentation.py @@ -37,7 +37,7 @@ def get_security_requirement(self, auto_schema): for permission in auto_schema.view.get_permissions(): if isinstance(permission, APIScopePermission): try: - scopes = permission.get_required_scopes(request, view) + scopes = permission._get_required_scopes(request, view) return [{self.name: scopes}] except (PermissionDenied, ImproperlyConfigured): # NOTE: This should never happen - it indicates that we shouldn't be including it in the docs diff --git a/posthog/api/feature_flag.py b/posthog/api/feature_flag.py index 5c1485a6d8636..06727c74bcf53 100644 --- a/posthog/api/feature_flag.py +++ b/posthog/api/feature_flag.py @@ -19,6 +19,8 @@ from rest_framework.response import Response from sentry_sdk import capture_exception from posthog.api.cohort import CohortSerializer +from posthog.rbac.access_control_api_mixin import AccessControlViewSetMixin +from posthog.rbac.user_access_control import UserAccessControlSerializerMixin from posthog.api.documentation import extend_schema from posthog.api.forbid_destroy_model import ForbidDestroyModel @@ -88,7 +90,9 @@ def has_object_permission(self, request: Request, view, feature_flag) -> bool: return can_user_edit_feature_flag(request, feature_flag) -class FeatureFlagSerializer(TaggedItemSerializerMixin, serializers.HyperlinkedModelSerializer): +class FeatureFlagSerializer( + TaggedItemSerializerMixin, UserAccessControlSerializerMixin, serializers.HyperlinkedModelSerializer +): created_by = UserBasicSerializer(read_only=True) # :TRICKY: Needed for backwards compatibility filters = serializers.DictField(source="get_filters", required=False) @@ -147,12 +151,16 @@ class Meta: "usage_dashboard", "analytics_dashboards", "has_enriched_analytics", + "user_access_level", "creation_context", ] def get_can_edit(self, feature_flag: FeatureFlag) -> bool: # TODO: make sure this isn't n+1 - return can_user_edit_feature_flag(self.context["request"], feature_flag) + return ( + can_user_edit_feature_flag(self.context["request"], feature_flag) + and self.get_user_access_level(feature_flag) == "editor" + ) # Simple flags are ones that only have rollout_percentage #  That means server side libraries are able to gate these flags without calling to the server @@ -435,6 +443,7 @@ class Meta: class FeatureFlagViewSet( TeamAndOrgViewSetMixin, + AccessControlViewSetMixin, TaggedItemViewSetMixin, ForbidDestroyModel, viewsets.ModelViewSet, diff --git a/posthog/api/insight.py b/posthog/api/insight.py index 77889e06212e6..32c24b3979f44 100644 --- a/posthog/api/insight.py +++ b/posthog/api/insight.py @@ -107,6 +107,8 @@ ClickHouseBurstRateThrottle, ClickHouseSustainedRateThrottle, ) +from posthog.rbac.access_control_api_mixin import AccessControlViewSetMixin +from posthog.rbac.user_access_control import UserAccessControlSerializerMixin from posthog.settings import CAPTURE_TIME_TO_SEE_DATA, SITE_URL from posthog.user_permissions import UserPermissionsSerializerMixin from posthog.utils import ( @@ -250,7 +252,7 @@ def _dashboard_tiles(self, instance): return [tile.dashboard_id for tile in instance.dashboard_tiles.all()] -class InsightSerializer(InsightBasicSerializer, UserPermissionsSerializerMixin): +class InsightSerializer(InsightBasicSerializer, UserPermissionsSerializerMixin, UserAccessControlSerializerMixin): result = serializers.SerializerMethodField() hasMore = serializers.SerializerMethodField() columns = serializers.SerializerMethodField() @@ -332,6 +334,7 @@ class Meta: "is_sample", "effective_restriction_level", "effective_privilege_level", + "user_access_level", "timezone", "is_cached", "query_status", @@ -348,6 +351,7 @@ class Meta: "is_sample", "effective_restriction_level", "effective_privilege_level", + "user_access_level", "timezone", "refreshing", "is_cached", @@ -710,6 +714,7 @@ def dashboard_tile_from_context(self, insight: Insight, dashboard: Optional[Dash ) class InsightViewSet( TeamAndOrgViewSetMixin, + AccessControlViewSetMixin, TaggedItemViewSetMixin, ForbidDestroyModel, viewsets.ModelViewSet, diff --git a/posthog/api/notebook.py b/posthog/api/notebook.py index 60dc30bde98e6..f68d2ddb0b26a 100644 --- a/posthog/api/notebook.py +++ b/posthog/api/notebook.py @@ -14,6 +14,8 @@ extend_schema_view, OpenApiExample, ) +from posthog.rbac.access_control_api_mixin import AccessControlViewSetMixin +from posthog.rbac.user_access_control import UserAccessControlSerializerMixin from rest_framework import serializers, viewsets from rest_framework.request import Request from rest_framework.response import Response @@ -95,7 +97,7 @@ class Meta: read_only_fields = fields -class NotebookSerializer(NotebookMinimalSerializer): +class NotebookSerializer(NotebookMinimalSerializer, UserAccessControlSerializerMixin): class Meta: model = Notebook fields = [ @@ -110,6 +112,7 @@ class Meta: "created_by", "last_modified_at", "last_modified_by", + "user_access_level", ] read_only_fields = [ "id", @@ -118,6 +121,7 @@ class Meta: "created_by", "last_modified_at", "last_modified_by", + "user_access_level", ] def create(self, validated_data: dict, *args, **kwargs) -> Notebook: @@ -235,7 +239,7 @@ def update(self, instance: Notebook, validated_data: dict, **kwargs) -> Notebook ], ) ) -class NotebookViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewsets.ModelViewSet): +class NotebookViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, ForbidDestroyModel, viewsets.ModelViewSet): scope_object = "notebook" queryset = Notebook.objects.all() filter_backends = [DjangoFilterBackend] diff --git a/posthog/api/organization.py b/posthog/api/organization.py index 6baeb3181504d..c522ca164c0b9 100644 --- a/posthog/api/organization.py +++ b/posthog/api/organization.py @@ -3,7 +3,6 @@ from django.db.models import Model, QuerySet from django.shortcuts import get_object_or_404 -from django.views import View from rest_framework import exceptions, permissions, serializers, viewsets from rest_framework.request import Request @@ -16,12 +15,13 @@ from posthog.event_usage import report_organization_deleted from posthog.models import Organization, User from posthog.models.async_deletion import AsyncDeletion, DeletionType +from posthog.rbac.user_access_control import UserAccessControlSerializerMixin from posthog.models.organization import OrganizationMembership from posthog.models.signals import mute_selected_signals from posthog.models.team.util import delete_bulky_postgres_data from posthog.models.uploaded_media import UploadedMedia from posthog.permissions import ( - CREATE_METHODS, + CREATE_ACTIONS, APIScopePermission, OrganizationAdminWritePermissions, TimeSensitiveActionPermission, @@ -40,7 +40,7 @@ def has_permission(self, request: Request, view) -> bool: if ( # Make multiple orgs only premium on self-hosted, since enforcement of this wouldn't make sense on Cloud not is_cloud() - and request.method in CREATE_METHODS + and view.action in CREATE_ACTIONS and ( user.organization is None or not user.organization.is_feature_available(AvailableFeature.ORGANIZATIONS_PROJECTS) @@ -52,7 +52,7 @@ def has_permission(self, request: Request, view) -> bool: class OrganizationPermissionsWithDelete(OrganizationAdminWritePermissions): - def has_object_permission(self, request: Request, view: View, object: Model) -> bool: + def has_object_permission(self, request: Request, view, object: Model) -> bool: if request.method in permissions.SAFE_METHODS: return True # TODO: Optimize so that this computation is only done once, on `OrganizationMemberPermissions` @@ -66,7 +66,9 @@ def has_object_permission(self, request: Request, view: View, object: Model) -> ) -class OrganizationSerializer(serializers.ModelSerializer, UserPermissionsSerializerMixin): +class OrganizationSerializer( + serializers.ModelSerializer, UserPermissionsSerializerMixin, UserAccessControlSerializerMixin +): membership_level = serializers.SerializerMethodField() teams = serializers.SerializerMethodField() projects = serializers.SerializerMethodField() @@ -127,7 +129,14 @@ def get_membership_level(self, organization: Organization) -> Optional[Organizat return membership.level if membership is not None else None def get_teams(self, instance: Organization) -> list[dict[str, Any]]: - visible_teams = instance.teams.filter(id__in=self.user_permissions.team_ids_visible_for_user) + # Support new access control system + visible_teams = ( + self.user_access_control.filter_queryset_by_access_level(instance.teams.all(), include_all_if_admin=True) + if self.user_access_control + else instance.teams.none() + ) + # Support old access control system + visible_teams = visible_teams.filter(id__in=self.user_permissions.team_ids_visible_for_user) return TeamBasicSerializer(visible_teams, context=self.context, many=True).data # type: ignore def get_projects(self, instance: Organization) -> list[dict[str, Any]]: diff --git a/posthog/api/organization_member.py b/posthog/api/organization_member.py index aaf1d5b802776..f176969ace2e3 100644 --- a/posthog/api/organization_member.py +++ b/posthog/api/organization_member.py @@ -2,7 +2,6 @@ from django.db.models import Model, Prefetch, QuerySet, F from django.shortcuts import get_object_or_404 -from django.views import View from django_otp.plugins.otp_totp.models import TOTPDevice from rest_framework import exceptions, mixins, serializers, viewsets from rest_framework.permissions import SAFE_METHODS, BasePermission @@ -23,7 +22,7 @@ class OrganizationMemberObjectPermissions(BasePermission): message = "Your cannot edit other organization members." - def has_object_permission(self, request: Request, view: View, membership: OrganizationMembership) -> bool: + def has_object_permission(self, request: Request, view, membership: OrganizationMembership) -> bool: if request.method in SAFE_METHODS: return True organization = extract_organization(membership, view) diff --git a/posthog/api/project.py b/posthog/api/project.py index 4bc6b97e38d9e..d7cda49e5c40b 100644 --- a/posthog/api/project.py +++ b/posthog/api/project.py @@ -15,6 +15,7 @@ TeamSerializer, validate_team_attrs, ) +from ee.api.rbac.access_control import AccessControlViewSetMixin from posthog.auth import PersonalAPIKeyAuthentication from posthog.event_usage import report_user_action from posthog.geoip import get_geoip_properties @@ -395,7 +396,7 @@ def update(self, instance: Project, validated_data: dict[str, Any]) -> Project: return instance -class ProjectViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet): +class ProjectViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, viewsets.ModelViewSet): """ Projects for the current organization. """ diff --git a/posthog/api/routing.py b/posthog/api/routing.py index 084ddcc94c3ae..7c59d73de662a 100644 --- a/posthog/api/routing.py +++ b/posthog/api/routing.py @@ -24,10 +24,12 @@ from posthog.models.user import User from posthog.permissions import ( APIScopePermission, + AccessControlPermission, OrganizationMemberPermissions, SharingTokenPermission, TeamMemberAccessPermission, ) +from posthog.rbac.user_access_control import UserAccessControl from posthog.user_permissions import UserPermissions if TYPE_CHECKING: @@ -101,7 +103,7 @@ def get_permissions(self): # NOTE: We define these here to make it hard _not_ to use them. If you want to override them, you have to # override the entire method. - permission_classes: list = [IsAuthenticated, APIScopePermission] + permission_classes: list = [IsAuthenticated, APIScopePermission, AccessControlPermission] if self._is_team_view or self._is_project_view: permission_classes.append(TeamMemberAccessPermission) @@ -145,19 +147,47 @@ def dangerously_get_queryset(self) -> QuerySet: raise NotImplementedError() def get_queryset(self) -> QuerySet: - try: - return self.dangerously_get_queryset() - except NotImplementedError: - pass + # Add a recursion guard + if getattr(self, "_in_get_queryset", False): + return super().get_queryset() - queryset = super().get_queryset() - # First of all make sure we do the custom filters before applying our own try: - queryset = self.safely_get_queryset(queryset) - except NotImplementedError: - pass + self._in_get_queryset = True + + try: + return self.dangerously_get_queryset() + except NotImplementedError: + pass + + queryset = super().get_queryset() + # First of all make sure we do the custom filters before applying our own + try: + queryset = self.safely_get_queryset(queryset) + except NotImplementedError: + pass + + queryset = self._filter_queryset_by_parents_lookups(queryset) + + if self.action != "list": + # NOTE: If we are getting an individual object then we don't filter it out here - this is handled by the permission logic + # The reason being, that if we filter out here already, we can't load the object which is required for checking access controls for it + return queryset - return self._filter_queryset_by_parents_lookups(queryset) + # NOTE: Half implemented - for admins, they may want to include listing of results that are not accessible (like private resources) + include_all_if_admin = self.request.GET.get("admin_include_all") == "true" + + # Additionally "projects" is a special one where we always want to include all projects if you're an org admin + if self.scope_object == "project": + include_all_if_admin = True + + # Only apply access control filter if we're not already in a recursive call + queryset = self.user_access_control.filter_queryset_by_access_level( + queryset, include_all_if_admin=include_all_if_admin + ) + + return queryset + finally: + self._in_get_queryset = False def dangerously_get_object(self) -> Any: """ @@ -408,3 +438,13 @@ def _get_team_from_request(self) -> Optional["Team"]: @cached_property def user_permissions(self) -> "UserPermissions": return UserPermissions(user=cast(User, self.request.user), team=self.team) + + @cached_property + def user_access_control(self) -> "UserAccessControl": + team: Optional[Team] = None + try: + team = self.team + except (Team.DoesNotExist, KeyError): + pass + + return UserAccessControl(user=cast(User, self.request.user), team=team, organization_id=self.organization_id) diff --git a/posthog/api/search.py b/posthog/api/search.py index cb5a779b0ed1f..fa33cbd52502f 100644 --- a/posthog/api/search.py +++ b/posthog/api/search.py @@ -100,6 +100,7 @@ def list(self, request: Request, **kw) -> HttpResponse: # add entities for entity_meta in [ENTITY_MAP[entity] for entity in entities]: klass_qs, entity_name = class_queryset( + view=self, klass=entity_meta.get("klass"), project_id=self.project_id, query=query, @@ -134,6 +135,7 @@ def process_query(query: str): def class_queryset( + view: TeamAndOrgViewSetMixin, klass: type[Model], project_id: int, query: str | None, @@ -145,6 +147,7 @@ def class_queryset( values = ["type", "result_id", "extra_fields"] qs: QuerySet[Any] = klass.objects.filter(team__project_id=project_id) # filter team + qs = view.user_access_control.filter_queryset_by_access_level(qs) # filter access level # :TRICKY: can't use an annotation here as `type` conflicts with a field on some models qs = qs.extra(select={"type": f"'{entity_type}'"}) # entity type diff --git a/posthog/api/team.py b/posthog/api/team.py index 6a948e002ec09..f2486a68fe8a0 100644 --- a/posthog/api/team.py +++ b/posthog/api/team.py @@ -24,6 +24,8 @@ load_activity, log_activity, ) +from posthog.rbac.access_control_api_mixin import AccessControlViewSetMixin +from posthog.rbac.user_access_control import UserAccessControlSerializerMixin from posthog.models.activity_logging.activity_page import activity_page_response from posthog.models.async_deletion import AsyncDeletion, DeletionType from posthog.models.group_type_mapping import GroupTypeMapping @@ -35,8 +37,9 @@ from posthog.models.team.util import delete_batch_exports, delete_bulky_postgres_data from posthog.models.utils import UUIDT from posthog.permissions import ( - CREATE_METHODS, + CREATE_ACTIONS, APIScopePermission, + AccessControlPermission, OrganizationAdminWritePermissions, OrganizationMemberPermissions, TeamMemberLightManagementPermission, @@ -57,7 +60,7 @@ class PremiumMultiProjectPermissions(BasePermission): # TODO: Rename to include message = "You must upgrade your PostHog plan to be able to create and manage multiple projects or environments." def has_permission(self, request: request.Request, view) -> bool: - if request.method in CREATE_METHODS: + if view.action in CREATE_ACTIONS: try: organization = get_organization_from_view(view) except ValueError: @@ -140,7 +143,7 @@ class Meta: ] -class TeamSerializer(serializers.ModelSerializer, UserPermissionsSerializerMixin): +class TeamSerializer(serializers.ModelSerializer, UserPermissionsSerializerMixin, UserAccessControlSerializerMixin): instance: Optional[Team] effective_membership_level = serializers.SerializerMethodField() @@ -207,6 +210,7 @@ class Meta: "live_events_token", "product_intents", "capture_dead_clicks", + "user_access_level", ) read_only_fields = ( "id", @@ -222,9 +226,11 @@ class Meta: "default_modifiers", "person_on_events_querying_enabled", "live_events_token", + "user_access_level", ) def get_effective_membership_level(self, team: Team) -> Optional[OrganizationMembership.Level]: + # TODO: Map from user_access_controls return self.user_permissions.team(team).effective_membership_level def get_has_group_types(self, team: Team) -> bool: @@ -444,7 +450,7 @@ def update(self, instance: Team, validated_data: dict[str, Any]) -> Team: return updated_team -class TeamViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet): +class TeamViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, viewsets.ModelViewSet): """ Projects for the current organization. """ @@ -481,6 +487,7 @@ def dangerously_get_permissions(self) -> list: permissions: list = [ IsAuthenticated, APIScopePermission, + AccessControlPermission, PremiumMultiProjectPermissions, *self.permission_classes, ] diff --git a/posthog/api/test/__snapshots__/test_action.ambr b/posthog/api/test/__snapshots__/test_action.ambr index d92da4aaf17a9..2b453c3a24b20 100644 --- a/posthog/api/test/__snapshots__/test_action.ambr +++ b/posthog/api/test/__snapshots__/test_action.ambr @@ -95,6 +95,214 @@ ''' # --- # name: TestActionApi.test_listing_actions_is_not_nplus1.10 + ''' + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.11 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.12 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '99' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '99' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.13 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.14 + ''' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.15 + ''' + SELECT "posthog_action"."id", + "posthog_action"."name", + "posthog_action"."team_id", + "posthog_action"."description", + "posthog_action"."created_at", + "posthog_action"."created_by_id", + "posthog_action"."deleted", + "posthog_action"."post_to_slack", + "posthog_action"."slack_message_format", + "posthog_action"."updated_at", + "posthog_action"."bytecode", + "posthog_action"."bytecode_error", + "posthog_action"."steps_json", + "posthog_action"."pinned_at", + "posthog_action"."is_calculating", + "posthog_action"."last_calculated_at", + COUNT("posthog_action_events"."event_id") AS "count", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in" + FROM "posthog_action" + LEFT OUTER JOIN "posthog_action_events" ON ("posthog_action"."id" = "posthog_action_events"."action_id") + INNER JOIN "posthog_team" ON ("posthog_action"."team_id" = "posthog_team"."id") + LEFT OUTER JOIN "posthog_user" ON ("posthog_action"."created_by_id" = "posthog_user"."id") + WHERE (NOT "posthog_action"."deleted" + AND "posthog_action"."team_id" = 99999 + AND "posthog_team"."project_id" = 99999) + GROUP BY "posthog_action"."id", + "posthog_user"."id" + ORDER BY "posthog_action"."last_calculated_at" DESC, + "posthog_action"."name" ASC + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.16 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -126,7 +334,7 @@ LIMIT 21 ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.11 +# name: TestActionApi.test_listing_actions_is_not_nplus1.17 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -189,7 +397,111 @@ LIMIT 21 ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.12 +# name: TestActionApi.test_listing_actions_is_not_nplus1.18 + ''' + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.19 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.2 + ''' + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.20 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '99' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '99' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.21 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -221,7 +533,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.13 +# name: TestActionApi.test_listing_actions_is_not_nplus1.22 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -247,7 +559,7 @@ LIMIT 21 ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.14 +# name: TestActionApi.test_listing_actions_is_not_nplus1.23 ''' SELECT "posthog_action"."id", "posthog_action"."name", @@ -305,7 +617,87 @@ "posthog_action"."name" ASC ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.2 +# name: TestActionApi.test_listing_actions_is_not_nplus1.3 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.4 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '99' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '99' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'action' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestActionApi.test_listing_actions_is_not_nplus1.5 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -337,7 +729,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.3 +# name: TestActionApi.test_listing_actions_is_not_nplus1.6 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -363,7 +755,7 @@ LIMIT 21 ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.4 +# name: TestActionApi.test_listing_actions_is_not_nplus1.7 ''' SELECT "posthog_action"."id", "posthog_action"."name", @@ -421,7 +813,7 @@ "posthog_action"."name" ASC ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.5 +# name: TestActionApi.test_listing_actions_is_not_nplus1.8 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -453,7 +845,7 @@ LIMIT 21 ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.6 +# name: TestActionApi.test_listing_actions_is_not_nplus1.9 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -516,119 +908,3 @@ LIMIT 21 ''' # --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.7 - ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.8 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestActionApi.test_listing_actions_is_not_nplus1.9 - ''' - SELECT "posthog_action"."id", - "posthog_action"."name", - "posthog_action"."team_id", - "posthog_action"."description", - "posthog_action"."created_at", - "posthog_action"."created_by_id", - "posthog_action"."deleted", - "posthog_action"."post_to_slack", - "posthog_action"."slack_message_format", - "posthog_action"."updated_at", - "posthog_action"."bytecode", - "posthog_action"."bytecode_error", - "posthog_action"."steps_json", - "posthog_action"."pinned_at", - "posthog_action"."is_calculating", - "posthog_action"."last_calculated_at", - COUNT("posthog_action_events"."event_id") AS "count", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_action" - LEFT OUTER JOIN "posthog_action_events" ON ("posthog_action"."id" = "posthog_action_events"."action_id") - INNER JOIN "posthog_team" ON ("posthog_action"."team_id" = "posthog_team"."id") - LEFT OUTER JOIN "posthog_user" ON ("posthog_action"."created_by_id" = "posthog_user"."id") - WHERE (NOT "posthog_action"."deleted" - AND "posthog_action"."team_id" = 99999 - AND "posthog_team"."project_id" = 99999) - GROUP BY "posthog_action"."id", - "posthog_user"."id" - ORDER BY "posthog_action"."last_calculated_at" DESC, - "posthog_action"."name" ASC - ''' -# --- diff --git a/posthog/api/test/__snapshots__/test_annotation.ambr b/posthog/api/test/__snapshots__/test_annotation.ambr index d7871ab1851c5..457607fc74fc8 100644 --- a/posthog/api/test/__snapshots__/test_annotation.ambr +++ b/posthog/api/test/__snapshots__/test_annotation.ambr @@ -96,68 +96,85 @@ # --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.10 ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) LIMIT 21 ''' # --- # name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.11 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '107' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '107' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.12 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -189,7 +206,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.12 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.13 ''' SELECT COUNT(*) AS "__count" FROM "posthog_annotation" @@ -199,7 +216,7 @@ OR "posthog_annotation"."team_id" = 99999)) ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.13 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.14 ''' SELECT "posthog_annotation"."id", "posthog_annotation"."content", @@ -280,49 +297,7 @@ LIMIT 1000 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.2 - ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.3 - ''' - SELECT COUNT(*) AS "__count" - FROM "posthog_annotation" - WHERE (NOT "posthog_annotation"."deleted" - AND (("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid - AND "posthog_annotation"."scope" = 'organization') - OR "posthog_annotation"."team_id" = 99999)) - ''' -# --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.4 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.15 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -354,7 +329,7 @@ LIMIT 21 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.5 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.16 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -417,7 +392,111 @@ LIMIT 21 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.6 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.17 + ''' + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.18 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.19 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '107' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '107' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.2 + ''' + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.20 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -449,7 +528,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.7 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.21 ''' SELECT COUNT(*) AS "__count" FROM "posthog_annotation" @@ -459,7 +538,7 @@ OR "posthog_annotation"."team_id" = 99999)) ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.8 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.22 ''' SELECT "posthog_annotation"."id", "posthog_annotation"."content", @@ -540,7 +619,129 @@ LIMIT 1000 ''' # --- -# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.9 +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.3 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.4 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '107' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '107' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'annotation' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.5 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.6 + ''' + SELECT COUNT(*) AS "__count" + FROM "posthog_annotation" + WHERE (NOT "posthog_annotation"."deleted" + AND (("posthog_annotation"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_annotation"."scope" = 'organization') + OR "posthog_annotation"."team_id" = 99999)) + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.7 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -572,3 +773,78 @@ LIMIT 21 ''' # --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.8 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestAnnotation.test_retrieving_annotation_is_not_n_plus_1.9 + ''' + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 + ''' +# --- diff --git a/posthog/api/test/__snapshots__/test_api_docs.ambr b/posthog/api/test/__snapshots__/test_api_docs.ambr index 8105280e6a538..42c03569e8f25 100644 --- a/posthog/api/test/__snapshots__/test_api_docs.ambr +++ b/posthog/api/test/__snapshots__/test_api_docs.ambr @@ -6,7 +6,6 @@ '/home/runner/work/posthog/posthog/ee/api/explicit_team_member.py: Warning [ExplicitTeamMemberViewSet]: could not derive type of path parameter "project_id" because model "ee.models.explicit_team_membership.ExplicitTeamMembership" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".', '/home/runner/work/posthog/posthog/ee/api/feature_flag_role_access.py: Warning [FeatureFlagRoleAccessViewSet]: could not derive type of path parameter "project_id" because model "ee.models.feature_flag_role_access.FeatureFlagRoleAccess" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".', '/home/runner/work/posthog/posthog/ee/api/rbac/role.py: Warning [RoleMembershipViewSet]: could not derive type of path parameter "organization_id" because model "ee.models.rbac.role.RoleMembership" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".', - '/home/runner/work/posthog/posthog/ee/api/rbac/role.py: Warning [RoleViewSet > RoleSerializer]: unable to resolve type hint for function "get_associated_flags". Consider using a type hint or @extend_schema_field. Defaulting to string.', '/home/runner/work/posthog/posthog/ee/api/rbac/role.py: Warning [RoleViewSet > RoleSerializer]: unable to resolve type hint for function "get_members". Consider using a type hint or @extend_schema_field. Defaulting to string.', '/home/runner/work/posthog/posthog/ee/api/subscription.py: Warning [SubscriptionViewSet > SubscriptionSerializer]: unable to resolve type hint for function "summary". Consider using a type hint or @extend_schema_field. Defaulting to string.', '/home/runner/work/posthog/posthog/ee/api/subscription.py: Warning [SubscriptionViewSet]: could not derive type of path parameter "project_id" because model "posthog.models.subscription.Subscription" contained no such field. Consider annotating parameter with @extend_schema. Defaulting to "string".', diff --git a/posthog/api/test/__snapshots__/test_decide.ambr b/posthog/api/test/__snapshots__/test_decide.ambr index 30fb4248b0b53..a7be20804014f 100644 --- a/posthog/api/test/__snapshots__/test_decide.ambr +++ b/posthog/api/test/__snapshots__/test_decide.ambr @@ -64,6 +64,358 @@ ''' # --- # name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.10 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.11 + ''' + SELECT "posthog_team"."id", + "posthog_team"."organization_id", + "posthog_team"."access_control" + FROM "posthog_team" + WHERE "posthog_team"."organization_id" IN ('00000000-0000-0000-0000-000000000000'::uuid) + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.12 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.13 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.14 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.15 + ''' + SELECT "posthog_team"."id", + "posthog_team"."organization_id", + "posthog_team"."access_control" + FROM "posthog_team" + WHERE "posthog_team"."organization_id" IN ('00000000-0000-0000-0000-000000000000'::uuid) + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.16 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.17 + ''' + SELECT "posthog_hogfunction"."id", + "posthog_hogfunction"."team_id", + "posthog_hogfunction"."name", + "posthog_hogfunction"."description", + "posthog_hogfunction"."created_at", + "posthog_hogfunction"."created_by_id", + "posthog_hogfunction"."deleted", + "posthog_hogfunction"."updated_at", + "posthog_hogfunction"."enabled", + "posthog_hogfunction"."type", + "posthog_hogfunction"."icon_url", + "posthog_hogfunction"."hog", + "posthog_hogfunction"."bytecode", + "posthog_hogfunction"."inputs_schema", + "posthog_hogfunction"."inputs", + "posthog_hogfunction"."encrypted_inputs", + "posthog_hogfunction"."filters", + "posthog_hogfunction"."masking", + "posthog_hogfunction"."template_id", + "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_hogfunction" + INNER JOIN "posthog_team" ON ("posthog_hogfunction"."team_id" = "posthog_team"."id") + WHERE ("posthog_hogfunction"."team_id" = 99999 + AND "posthog_hogfunction"."filters" @> '{"filter_test_accounts": true}'::jsonb) + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.18 + ''' + SELECT 1 AS "a" + FROM "posthog_grouptypemapping" + WHERE "posthog_grouptypemapping"."team_id" = 99999 + LIMIT 1 + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.19 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.2 + ''' + SELECT "posthog_team"."id", + "posthog_team"."organization_id", + "posthog_team"."access_control" + FROM "posthog_team" + WHERE "posthog_team"."organization_id" IN ('00000000-0000-0000-0000-000000000000'::uuid) + ''' +# --- +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.20 ''' SELECT "posthog_productintent"."id", "posthog_productintent"."team_id", @@ -77,7 +429,7 @@ WHERE "posthog_productintent"."team_id" = 99999 ''' # --- -# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.11 +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.21 ''' SELECT "posthog_productintent"."product_type", "posthog_productintent"."created_at", @@ -87,7 +439,7 @@ WHERE "posthog_productintent"."team_id" = 99999 ''' # --- -# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.12 +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.22 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -119,7 +471,7 @@ LIMIT 21 ''' # --- -# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.13 +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.23 ''' SELECT "posthog_featureflag"."id", "posthog_featureflag"."key", @@ -142,7 +494,7 @@ AND "posthog_featureflag"."team_id" = 99999) ''' # --- -# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.14 +# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.24 ''' SELECT "posthog_pluginconfig"."id", "posthog_pluginconfig"."web_token", @@ -158,15 +510,6 @@ AND "posthog_pluginconfig"."team_id" = 99999) ''' # --- -# name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.2 - ''' - SELECT "posthog_team"."id", - "posthog_team"."organization_id", - "posthog_team"."access_control" - FROM "posthog_team" - WHERE "posthog_team"."organization_id" IN ('00000000-0000-0000-0000-000000000000'::uuid) - ''' -# --- # name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.3 ''' SELECT "posthog_team"."id", @@ -266,7 +609,9 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- # name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.5 @@ -312,163 +657,117 @@ # --- # name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.7 ''' - SELECT "posthog_hogfunction"."id", - "posthog_hogfunction"."team_id", - "posthog_hogfunction"."name", - "posthog_hogfunction"."description", - "posthog_hogfunction"."created_at", - "posthog_hogfunction"."created_by_id", - "posthog_hogfunction"."deleted", - "posthog_hogfunction"."updated_at", - "posthog_hogfunction"."enabled", - "posthog_hogfunction"."type", - "posthog_hogfunction"."icon_url", - "posthog_hogfunction"."hog", - "posthog_hogfunction"."bytecode", - "posthog_hogfunction"."inputs_schema", - "posthog_hogfunction"."inputs", - "posthog_hogfunction"."encrypted_inputs", - "posthog_hogfunction"."filters", - "posthog_hogfunction"."masking", - "posthog_hogfunction"."template_id", - "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_hogfunction" - INNER JOIN "posthog_team" ON ("posthog_hogfunction"."team_id" = "posthog_team"."id") - WHERE ("posthog_hogfunction"."team_id" = 99999 - AND "posthog_hogfunction"."filters" @> '{"filter_test_accounts": true}'::jsonb) + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- # name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.8 ''' - SELECT 1 AS "a" - FROM "posthog_grouptypemapping" - WHERE "posthog_grouptypemapping"."team_id" = 99999 - LIMIT 1 + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- # name: TestDecide.test_decide_doesnt_error_out_when_database_is_down.9 ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '253' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '253' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)) ''' # --- # name: TestDecide.test_flag_with_behavioural_cohorts diff --git a/posthog/api/test/__snapshots__/test_element.ambr b/posthog/api/test/__snapshots__/test_element.ambr index d6bceb987c788..414a8a1831062 100644 --- a/posthog/api/test/__snapshots__/test_element.ambr +++ b/posthog/api/test/__snapshots__/test_element.ambr @@ -130,28 +130,86 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- # name: TestElement.test_element_stats_postgres_queries_are_as_expected.3 ''' - SELECT "posthog_instancesetting"."id", - "posthog_instancesetting"."key", - "posthog_instancesetting"."raw_value" - FROM "posthog_instancesetting" - WHERE "posthog_instancesetting"."key" = 'constance:posthog:RATE_LIMIT_ENABLED' - ORDER BY "posthog_instancesetting"."id" ASC - LIMIT 1 + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '272' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '272' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'INTERNAL' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'INTERNAL' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'INTERNAL' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'INTERNAL' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) ''' # --- # name: TestElement.test_element_stats_postgres_queries_are_as_expected.4 ''' - SELECT "posthog_instancesetting"."id", - "posthog_instancesetting"."key", - "posthog_instancesetting"."raw_value" - FROM "posthog_instancesetting" - WHERE "posthog_instancesetting"."key" = 'constance:posthog:HEATMAP_SAMPLE_N' - ORDER BY "posthog_instancesetting"."id" ASC - LIMIT 1 + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- diff --git a/posthog/api/test/__snapshots__/test_feature_flag.ambr b/posthog/api/test/__snapshots__/test_feature_flag.ambr index 177849ed4b92e..9662d335f039e 100644 --- a/posthog/api/test/__snapshots__/test_feature_flag.ambr +++ b/posthog/api/test/__snapshots__/test_feature_flag.ambr @@ -1668,6 +1668,69 @@ ''' # --- # name: TestFeatureFlag.test_creating_static_cohort.10 + ''' + SELECT "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_person" + WHERE ("posthog_person"."team_id" = 99999 + AND ("posthog_person"."properties" -> 'key') = '"value"'::jsonb + AND "posthog_person"."properties" ? 'key' + AND NOT (("posthog_person"."properties" -> 'key') = 'null'::jsonb)) + ORDER BY "posthog_person"."id" ASC + LIMIT 10000 + ''' +# --- +# name: TestFeatureFlag.test_creating_static_cohort.11 + ''' + SELECT "posthog_persondistinctid"."id", + "posthog_persondistinctid"."team_id", + "posthog_persondistinctid"."person_id", + "posthog_persondistinctid"."distinct_id", + "posthog_persondistinctid"."version" + FROM "posthog_persondistinctid" + WHERE ("posthog_persondistinctid"."id" IN + (SELECT U0."id" + FROM "posthog_persondistinctid" U0 + WHERE U0."person_id" = ("posthog_persondistinctid"."person_id") + LIMIT 3) + AND "posthog_persondistinctid"."person_id" IN (1, + 2, + 3, + 4, + 5 /* ... */)) + ''' +# --- +# name: TestFeatureFlag.test_creating_static_cohort.12 + ''' + SELECT "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_person" + WHERE ("posthog_person"."team_id" = 99999 + AND ("posthog_person"."properties" -> 'key') = '"value"'::jsonb + AND "posthog_person"."properties" ? 'key' + AND NOT (("posthog_person"."properties" -> 'key') = 'null'::jsonb)) + ORDER BY "posthog_person"."id" ASC + LIMIT 10000 + OFFSET 10000 + ''' +# --- +# name: TestFeatureFlag.test_creating_static_cohort.13 ''' SELECT "posthog_person"."uuid" FROM "posthog_person" @@ -1681,7 +1744,7 @@ LIMIT 1))) ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.11 +# name: TestFeatureFlag.test_creating_static_cohort.14 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -1751,7 +1814,7 @@ LIMIT 21 ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.12 +# name: TestFeatureFlag.test_creating_static_cohort.15 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -1821,7 +1884,7 @@ LIMIT 21 ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.13 +# name: TestFeatureFlag.test_creating_static_cohort.16 ''' SELECT "posthog_experiment"."id", "posthog_experiment"."name", @@ -1847,7 +1910,7 @@ WHERE "posthog_experiment"."exposure_cohort_id" = 99999 ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.14 +# name: TestFeatureFlag.test_creating_static_cohort.17 ''' /* user_id:0 celery:posthog.tasks.calculate_cohort.insert_cohort_from_feature_flag */ SELECT count(DISTINCT person_id) @@ -1856,7 +1919,7 @@ AND cohort_id = 99999 ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.15 +# name: TestFeatureFlag.test_creating_static_cohort.18 ''' /* user_id:0 request:_snapshot_ */ SELECT id @@ -1877,6 +1940,98 @@ ''' # --- # name: TestFeatureFlag.test_creating_static_cohort.2 + ''' + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestFeatureFlag.test_creating_static_cohort.3 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestFeatureFlag.test_creating_static_cohort.4 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '310' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '310' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'feature_flag' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'feature_flag' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'feature_flag' + AND "ee_accesscontrol"."resource_id" = '130' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'feature_flag' + AND "ee_accesscontrol"."resource_id" = '130' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestFeatureFlag.test_creating_static_cohort.5 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -1908,7 +2063,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.3 +# name: TestFeatureFlag.test_creating_static_cohort.6 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -1934,7 +2089,7 @@ LIMIT 21 ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.4 +# name: TestFeatureFlag.test_creating_static_cohort.7 ''' SELECT "posthog_featureflag"."id", "posthog_featureflag"."key", @@ -1985,7 +2140,7 @@ LIMIT 21 ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.5 +# name: TestFeatureFlag.test_creating_static_cohort.8 ''' SELECT "posthog_featureflag"."id", "posthog_featureflag"."key", @@ -2008,7 +2163,7 @@ LIMIT 21 ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.6 +# name: TestFeatureFlag.test_creating_static_cohort.9 ''' SELECT "posthog_cohort"."id", "posthog_cohort"."name", @@ -2034,69 +2189,6 @@ LIMIT 21 ''' # --- -# name: TestFeatureFlag.test_creating_static_cohort.7 - ''' - SELECT "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_person" - WHERE ("posthog_person"."team_id" = 99999 - AND ("posthog_person"."properties" -> 'key') = '"value"'::jsonb - AND "posthog_person"."properties" ? 'key' - AND NOT (("posthog_person"."properties" -> 'key') = 'null'::jsonb)) - ORDER BY "posthog_person"."id" ASC - LIMIT 10000 - ''' -# --- -# name: TestFeatureFlag.test_creating_static_cohort.8 - ''' - SELECT "posthog_persondistinctid"."id", - "posthog_persondistinctid"."team_id", - "posthog_persondistinctid"."person_id", - "posthog_persondistinctid"."distinct_id", - "posthog_persondistinctid"."version" - FROM "posthog_persondistinctid" - WHERE ("posthog_persondistinctid"."id" IN - (SELECT U0."id" - FROM "posthog_persondistinctid" U0 - WHERE U0."person_id" = ("posthog_persondistinctid"."person_id") - LIMIT 3) - AND "posthog_persondistinctid"."person_id" IN (1, - 2, - 3, - 4, - 5 /* ... */)) - ''' -# --- -# name: TestFeatureFlag.test_creating_static_cohort.9 - ''' - SELECT "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_person" - WHERE ("posthog_person"."team_id" = 99999 - AND ("posthog_person"."properties" -> 'key') = '"value"'::jsonb - AND "posthog_person"."properties" ? 'key' - AND NOT (("posthog_person"."properties" -> 'key') = 'null'::jsonb)) - ORDER BY "posthog_person"."id" ASC - LIMIT 10000 - OFFSET 10000 - ''' -# --- # name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db ''' WITH target_person_ids AS diff --git a/posthog/api/test/__snapshots__/test_insight.ambr b/posthog/api/test/__snapshots__/test_insight.ambr index 0245b9c88b44d..2e95c4f809659 100644 --- a/posthog/api/test/__snapshots__/test_insight.ambr +++ b/posthog/api/test/__snapshots__/test_insight.ambr @@ -789,6 +789,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -797,6 +804,139 @@ ''' # --- # name: TestInsight.test_listing_insights_does_not_nplus1.11 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestInsight.test_listing_insights_does_not_nplus1.12 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestInsight.test_listing_insights_does_not_nplus1.13 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -814,7 +954,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.12 +# name: TestInsight.test_listing_insights_does_not_nplus1.14 ''' SELECT "posthog_dashboarditem"."id", "posthog_dashboarditem"."name", @@ -849,7 +989,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.13 +# name: TestInsight.test_listing_insights_does_not_nplus1.15 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -873,7 +1013,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.14 +# name: TestInsight.test_listing_insights_does_not_nplus1.16 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -943,7 +1083,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.15 +# name: TestInsight.test_listing_insights_does_not_nplus1.17 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -969,7 +1109,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.16 +# name: TestInsight.test_listing_insights_does_not_nplus1.18 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -994,7 +1134,7 @@ AND "posthog_dashboardtile"."insight_id" = 99999) ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.17 +# name: TestInsight.test_listing_insights_does_not_nplus1.19 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -1015,7 +1155,41 @@ AND "posthog_dashboardtile"."insight_id" = 99999) ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.18 +# name: TestInsight.test_listing_insights_does_not_nplus1.2 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestInsight.test_listing_insights_does_not_nplus1.20 ''' SELECT "posthog_dashboardtile"."dashboard_id" FROM "posthog_dashboardtile" @@ -1026,7 +1200,7 @@ AND "posthog_dashboardtile"."insight_id" = 99999) ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.19 +# name: TestInsight.test_listing_insights_does_not_nplus1.21 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -1054,46 +1228,14 @@ 5 /* ... */)) ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.2 - ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestInsight.test_listing_insights_does_not_nplus1.20 +# name: TestInsight.test_listing_insights_does_not_nplus1.22 ''' SELECT COUNT(*) AS "__count" FROM "posthog_dashboarditem" WHERE NOT ("posthog_dashboarditem"."deleted") ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.21 +# name: TestInsight.test_listing_insights_does_not_nplus1.23 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -1125,7 +1267,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.22 +# name: TestInsight.test_listing_insights_does_not_nplus1.24 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -1188,7 +1330,87 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.23 +# name: TestInsight.test_listing_insights_does_not_nplus1.25 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestInsight.test_listing_insights_does_not_nplus1.26 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '438' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '438' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestInsight.test_listing_insights_does_not_nplus1.27 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -1220,7 +1442,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.24 +# name: TestInsight.test_listing_insights_does_not_nplus1.28 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -1246,7 +1468,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.25 +# name: TestInsight.test_listing_insights_does_not_nplus1.29 ''' SELECT COUNT(*) AS "__count" FROM "posthog_dashboarditem" @@ -1255,7 +1477,53 @@ AND NOT ("posthog_dashboarditem"."deleted")) ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.26 +# name: TestInsight.test_listing_insights_does_not_nplus1.3 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '438' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '438' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestInsight.test_listing_insights_does_not_nplus1.30 ''' SELECT "posthog_dashboarditem"."id", "posthog_dashboarditem"."name", @@ -1410,7 +1678,7 @@ LIMIT 100 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.27 +# name: TestInsight.test_listing_insights_does_not_nplus1.31 ''' SELECT ("posthog_dashboardtile"."insight_id") AS "_prefetch_related_val_insight_id", "posthog_dashboard"."id", @@ -1524,7 +1792,7 @@ 5 /* ... */)) ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.28 +# name: TestInsight.test_listing_insights_does_not_nplus1.32 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -1650,7 +1918,7 @@ 5 /* ... */)) ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.29 +# name: TestInsight.test_listing_insights_does_not_nplus1.33 ''' SELECT "posthog_taggeditem"."id", "posthog_taggeditem"."tag_id", @@ -1668,7 +1936,39 @@ 5 /* ... */) ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.3 +# name: TestInsight.test_listing_insights_does_not_nplus1.4 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestInsight.test_listing_insights_does_not_nplus1.5 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -1693,25 +1993,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.30 - ''' - SELECT "posthog_taggeditem"."id", - "posthog_taggeditem"."tag_id", - "posthog_taggeditem"."dashboard_id", - "posthog_taggeditem"."insight_id", - "posthog_taggeditem"."event_definition_id", - "posthog_taggeditem"."property_definition_id", - "posthog_taggeditem"."action_id", - "posthog_taggeditem"."feature_flag_id" - FROM "posthog_taggeditem" - WHERE "posthog_taggeditem"."insight_id" IN (1, - 2, - 3, - 4, - 5 /* ... */) - ''' -# --- -# name: TestInsight.test_listing_insights_does_not_nplus1.4 +# name: TestInsight.test_listing_insights_does_not_nplus1.6 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -1774,7 +2056,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.5 +# name: TestInsight.test_listing_insights_does_not_nplus1.7 ''' SELECT "posthog_dashboarditem"."id", "posthog_dashboarditem"."name", @@ -1809,7 +2091,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.6 +# name: TestInsight.test_listing_insights_does_not_nplus1.8 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -1879,7 +2161,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.7 +# name: TestInsight.test_listing_insights_does_not_nplus1.9 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -1907,143 +2189,3 @@ 5 /* ... */)) ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.8 - ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestInsight.test_listing_insights_does_not_nplus1.9 - ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- diff --git a/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr b/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr index aa7aba9ddfbb7..351264ee04d8c 100644 --- a/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr +++ b/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr @@ -1155,6 +1155,40 @@ ''' # --- # name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.36 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.37 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -1179,26 +1213,38 @@ AND "posthog_featureflagdashboards"."feature_flag_id" = 99999) ''' # --- -# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.37 - ''' - SELECT "posthog_instancesetting"."id", - "posthog_instancesetting"."key", - "posthog_instancesetting"."raw_value" - FROM "posthog_instancesetting" - WHERE "posthog_instancesetting"."key" = 'constance:posthog:PERSON_ON_EVENTS_ENABLED' - ORDER BY "posthog_instancesetting"."id" ASC - LIMIT 1 - ''' -# --- # name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.38 ''' - SELECT "posthog_instancesetting"."id", - "posthog_instancesetting"."key", - "posthog_instancesetting"."raw_value" - FROM "posthog_instancesetting" - WHERE "posthog_instancesetting"."key" = 'constance:posthog:PERSON_ON_EVENTS_V2_ENABLED' - ORDER BY "posthog_instancesetting"."id" ASC - LIMIT 1 + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- # name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.39 diff --git a/posthog/api/test/__snapshots__/test_plugin.ambr b/posthog/api/test/__snapshots__/test_plugin.ambr index 4e5362f5b09f0..50037107d482e 100644 --- a/posthog/api/test/__snapshots__/test_plugin.ambr +++ b/posthog/api/test/__snapshots__/test_plugin.ambr @@ -84,6 +84,102 @@ ''' # --- # name: TestPluginAPI.test_listing_plugins_is_not_nplus1.11 + ''' + SELECT 1 AS "a" + FROM "posthog_organizationmembership" + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 1 + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.12 + ''' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.13 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.14 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'plugin' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'plugin' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)) + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.15 ''' SELECT COUNT(*) AS "__count" FROM "posthog_plugin" @@ -97,7 +193,7 @@ AND U1."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid))) ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.12 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.16 ''' SELECT "posthog_plugin"."id", "posthog_plugin"."organization_id", @@ -156,7 +252,7 @@ LIMIT 100 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.13 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.17 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -188,7 +284,7 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.14 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.18 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -214,7 +310,7 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.15 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.19 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -240,7 +336,33 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.16 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.2 + ''' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.20 ''' SELECT 1 AS "a" FROM "posthog_organizationmembership" @@ -249,7 +371,7 @@ LIMIT 1 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.17 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.21 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -275,7 +397,68 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.18 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.22 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.23 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'plugin' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'plugin' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)) + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.24 ''' SELECT COUNT(*) AS "__count" FROM "posthog_plugin" @@ -289,7 +472,7 @@ AND U1."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid))) ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.19 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.25 ''' SELECT "posthog_plugin"."id", "posthog_plugin"."organization_id", @@ -348,33 +531,7 @@ LIMIT 100 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.2 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.20 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.26 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -406,7 +563,7 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.21 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.27 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -432,7 +589,7 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.22 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.28 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -458,7 +615,7 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.23 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.29 ''' SELECT 1 AS "a" FROM "posthog_organizationmembership" @@ -467,7 +624,16 @@ LIMIT 1 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.24 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.3 + ''' + SELECT 1 AS "a" + FROM "posthog_organizationmembership" + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 1 + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.30 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -493,7 +659,68 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.25 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.31 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.32 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'plugin' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'plugin' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)) + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.33 ''' SELECT COUNT(*) AS "__count" FROM "posthog_plugin" @@ -507,7 +734,7 @@ AND U1."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid))) ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.26 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.34 ''' SELECT "posthog_plugin"."id", "posthog_plugin"."organization_id", @@ -566,15 +793,6 @@ LIMIT 100 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.3 - ''' - SELECT 1 AS "a" - FROM "posthog_organizationmembership" - WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid - AND "posthog_organizationmembership"."user_id" = 99999) - LIMIT 1 - ''' -# --- # name: TestPluginAPI.test_listing_plugins_is_not_nplus1.4 ''' SELECT "posthog_organization"."id", @@ -602,6 +820,67 @@ ''' # --- # name: TestPluginAPI.test_listing_plugins_is_not_nplus1.5 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.6 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + INNER JOIN "posthog_team" ON ("ee_accesscontrol"."team_id" = "posthog_team"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'plugin' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'plugin' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)) + ''' +# --- +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.7 ''' SELECT COUNT(*) AS "__count" FROM "posthog_plugin" @@ -615,7 +894,7 @@ AND U1."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid))) ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.6 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.8 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -647,33 +926,7 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.7 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.8 +# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.9 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -699,12 +952,3 @@ LIMIT 21 ''' # --- -# name: TestPluginAPI.test_listing_plugins_is_not_nplus1.9 - ''' - SELECT 1 AS "a" - FROM "posthog_organizationmembership" - WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid - AND "posthog_organizationmembership"."user_id" = 99999) - LIMIT 1 - ''' -# --- diff --git a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr index 12d1f6f8fff56..7d964fa88087f 100644 --- a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr +++ b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr @@ -95,6 +95,52 @@ ''' # --- # name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.10 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.11 + ''' + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.12 ''' SELECT "posthog_dashboardtile"."dashboard_id" FROM "posthog_dashboardtile" @@ -105,7 +151,7 @@ AND "posthog_dashboardtile"."insight_id" = 99999) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.11 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.13 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -133,7 +179,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.12 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.14 ''' SELECT "posthog_tag"."name" FROM "posthog_taggeditem" @@ -141,7 +187,7 @@ WHERE "posthog_taggeditem"."insight_id" = 99999 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.13 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.15 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -173,7 +219,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.14 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.16 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -236,7 +282,87 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.15 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.17 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.18 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '1' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '1' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.19 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -268,7 +394,41 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.16 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.2 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.20 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -322,7 +482,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.17 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.21 ''' SELECT "posthog_sharingconfiguration"."id", "posthog_sharingconfiguration"."team_id", @@ -340,7 +500,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.18 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.22 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -526,7 +686,7 @@ ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.19 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.23 ''' SELECT "posthog_insightcachingstate"."id", "posthog_insightcachingstate"."team_id", @@ -547,39 +707,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.2 - ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.20 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.24 ''' SELECT ("posthog_dashboardtile"."insight_id") AS "_prefetch_related_val_insight_id", "posthog_dashboard"."id", @@ -616,7 +744,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.21 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.25 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -641,7 +769,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.22 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.26 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -668,7 +796,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.23 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.27 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -855,7 +983,7 @@ ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.24 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.28 ''' SELECT "posthog_insightcachingstate"."id", "posthog_insightcachingstate"."team_id", @@ -876,7 +1004,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.25 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.29 ''' SELECT ("posthog_dashboardtile"."insight_id") AS "_prefetch_related_val_insight_id", "posthog_dashboard"."id", @@ -913,7 +1041,53 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.26 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.3 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.30 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -938,7 +1112,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.27 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.31 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -965,7 +1139,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.28 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.32 ''' SELECT "posthog_taggeditem"."id", "posthog_taggeditem"."tag_id", @@ -987,7 +1161,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.29 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.33 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -1015,32 +1189,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.3 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" = 99999) - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.30 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.34 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -1066,7 +1215,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.31 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.35 ''' SELECT "posthog_tag"."name" FROM "posthog_taggeditem" @@ -1075,6 +1224,38 @@ ''' # --- # name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.4 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.5 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -1095,17 +1276,42 @@ "posthog_dashboard"."is_shared" FROM "posthog_dashboard" WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" IN (1, - 2, - 3, - 4, - 5 /* ... */)) + AND "posthog_dashboard"."id" = 99999) + LIMIT 21 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.5 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.6 ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" IN (1, + 2, + 3, + 4, + 5 /* ... */)) + ''' +# --- +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.7 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", "posthog_team"."organization_id", "posthog_team"."project_id", "posthog_team"."api_token", @@ -1172,7 +1378,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.6 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.8 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -1242,7 +1448,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.7 +# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.9 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -1268,52 +1474,6 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.8 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_adding_insights_is_not_nplus1_for_gets.9 - ''' - SELECT "posthog_dashboardtile"."id", - "posthog_dashboardtile"."dashboard_id", - "posthog_dashboardtile"."insight_id", - "posthog_dashboardtile"."text_id", - "posthog_dashboardtile"."layouts", - "posthog_dashboardtile"."color", - "posthog_dashboardtile"."filters_hash", - "posthog_dashboardtile"."last_refresh", - "posthog_dashboardtile"."refreshing", - "posthog_dashboardtile"."refresh_attempt", - "posthog_dashboardtile"."deleted" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- # name: TestDashboard.test_listing_dashboards_is_not_nplus1 ''' SELECT "posthog_user"."id", @@ -1465,6 +1625,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -1473,6 +1640,139 @@ ''' # --- # name: TestDashboard.test_listing_dashboards_is_not_nplus1.11 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.12 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.13 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -1490,7 +1790,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.12 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.14 ''' SELECT "posthog_dashboarditem"."id", "posthog_dashboarditem"."name", @@ -1525,7 +1825,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.13 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.15 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -1549,7 +1849,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.14 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.16 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -1619,7 +1919,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.15 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.17 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -1645,7 +1945,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.16 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.18 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -1671,7 +1971,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.17 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.19 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -1734,53 +2034,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.18 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.19 - ''' - SELECT "posthog_dashboardtile"."id", - "posthog_dashboardtile"."dashboard_id", - "posthog_dashboardtile"."insight_id", - "posthog_dashboardtile"."text_id", - "posthog_dashboardtile"."layouts", - "posthog_dashboardtile"."color", - "posthog_dashboardtile"."filters_hash", - "posthog_dashboardtile"."last_refresh", - "posthog_dashboardtile"."refreshing", - "posthog_dashboardtile"."refresh_attempt", - "posthog_dashboardtile"."deleted" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.2 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.2 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -1809,10 +2063,58 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- # name: TestDashboard.test_listing_dashboards_is_not_nplus1.20 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.21 + ''' + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.22 ''' SELECT "posthog_dashboardtile"."dashboard_id" FROM "posthog_dashboardtile" @@ -1823,7 +2125,7 @@ AND "posthog_dashboardtile"."insight_id" = 99999) ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.21 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.23 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -1851,7 +2153,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.22 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.24 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -1883,7 +2185,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.23 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.25 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -1946,7 +2248,87 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.24 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.26 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.27 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.28 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -1978,7 +2360,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.25 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.29 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -2004,7 +2386,53 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.26 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.3 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.30 ''' SELECT COUNT(*) AS "__count" FROM "posthog_dashboard" @@ -2013,7 +2441,7 @@ AND NOT ("posthog_dashboard"."deleted")) ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.27 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.31 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -2068,7 +2496,7 @@ LIMIT 300 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.28 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.32 ''' SELECT "posthog_sharingconfiguration"."id", "posthog_sharingconfiguration"."team_id", @@ -2086,7 +2514,105 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.3 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.33 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '55' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '55' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '56' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '56' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '57' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '57' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '58' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '58' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '59' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '59' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.4 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.5 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -2111,7 +2637,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.4 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.6 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -2174,7 +2700,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.5 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.7 ''' SELECT "posthog_dashboarditem"."id", "posthog_dashboarditem"."name", @@ -2209,7 +2735,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.6 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.8 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -2279,7 +2805,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.7 +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.9 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -2307,7 +2833,39 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.8 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles + ''' + SELECT "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in" + FROM "posthog_user" + WHERE "posthog_user"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.1 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -2363,13 +2921,6 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -2377,7 +2928,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_listing_dashboards_is_not_nplus1.9 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.10 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -2447,53 +2998,45 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles - ''' - SELECT "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_user" - WHERE "posthog_user"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.1 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.100 ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE "posthog_dashboard"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.101 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", "posthog_team"."ingested_event", "posthog_team"."autocapture_opt_out", "posthog_team"."autocapture_web_vitals_opt_in", @@ -2535,6 +3078,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -2542,48 +3092,61 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.10 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.102 ''' - SELECT "posthog_dashboardtile"."id", - "posthog_dashboardtile"."dashboard_id", - "posthog_dashboardtile"."insight_id", - "posthog_dashboardtile"."text_id", - "posthog_dashboardtile"."layouts", - "posthog_dashboardtile"."color", - "posthog_dashboardtile"."filters_hash", - "posthog_dashboardtile"."last_refresh", - "posthog_dashboardtile"."refreshing", - "posthog_dashboardtile"."refresh_attempt", - "posthog_dashboardtile"."deleted", - "posthog_dashboarditem"."id", - "posthog_dashboarditem"."name", - "posthog_dashboarditem"."derived_name", - "posthog_dashboarditem"."description", - "posthog_dashboarditem"."team_id", - "posthog_dashboarditem"."filters", - "posthog_dashboarditem"."filters_hash", - "posthog_dashboarditem"."query", - "posthog_dashboarditem"."order", - "posthog_dashboarditem"."deleted", - "posthog_dashboarditem"."saved", - "posthog_dashboarditem"."created_at", - "posthog_dashboarditem"."refreshing", - "posthog_dashboarditem"."created_by_id", - "posthog_dashboarditem"."is_sample", - "posthog_dashboarditem"."short_id", - "posthog_dashboarditem"."favorited", - "posthog_dashboarditem"."refresh_attempt", - "posthog_dashboarditem"."last_modified_at", - "posthog_dashboarditem"."last_modified_by_id", - "posthog_dashboarditem"."dashboard_id", - "posthog_dashboarditem"."last_refresh", - "posthog_dashboarditem"."layouts", - "posthog_dashboarditem"."color", - "posthog_dashboarditem"."dive_dashboard_id", - "posthog_dashboarditem"."updated_at", - "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags", - "posthog_team"."id", + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.103 + ''' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.104 + ''' + SELECT "posthog_team"."id", "posthog_team"."uuid", "posthog_team"."organization_id", "posthog_team"."project_id", @@ -2637,93 +3200,121 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in", - T6."id", - T6."password", - T6."last_login", - T6."first_name", - T6."last_name", - T6."is_staff", - T6."date_joined", - T6."uuid", - T6."current_organization_id", - T6."current_team_id", - T6."email", - T6."pending_email", - T6."temporary_token", - T6."distinct_id", - T6."is_email_verified", - T6."requested_password_reset_at", - T6."has_seen_product_intro_for", - T6."strapi_id", - T6."is_active", - T6."theme_mode", - T6."partial_notification_settings", - T6."anonymize_data", - T6."toolbar_mode", - T6."hedgehog_config", - T6."events_column_config", - T6."email_opt_in", - "posthog_text"."id", - "posthog_text"."body", - "posthog_text"."created_by_id", - "posthog_text"."last_modified_at", - "posthog_text"."last_modified_by_id", - "posthog_text"."team_id" + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.105 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.106 + ''' + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted" FROM "posthog_dashboardtile" INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_dashboardtile"."insight_id" = "posthog_dashboarditem"."id") - LEFT OUTER JOIN "posthog_team" ON ("posthog_dashboarditem"."team_id" = "posthog_team"."id") - LEFT OUTER JOIN "posthog_user" ON ("posthog_dashboarditem"."created_by_id" = "posthog_user"."id") - LEFT OUTER JOIN "posthog_user" T6 ON ("posthog_dashboarditem"."last_modified_by_id" = T6."id") - LEFT OUTER JOIN "posthog_text" ON ("posthog_dashboardtile"."text_id" = "posthog_text"."id") WHERE (NOT ("posthog_dashboardtile"."deleted" AND "posthog_dashboardtile"."deleted" IS NOT NULL) AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."dashboard_id" = 99999 - AND NOT ("posthog_dashboard"."deleted" - AND "posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND (NOT "posthog_dashboarditem"."deleted" - OR "posthog_dashboardtile"."insight_id" IS NULL)) - ORDER BY "posthog_dashboarditem"."order" ASC + AND "posthog_dashboardtile"."insight_id" = 99999) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.100 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.107 + ''' + SELECT "posthog_dashboardtile"."dashboard_id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.108 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" IN (1, + 2, + 3, + 4, + 5 /* ... */)) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.109 + ''' + SELECT "posthog_tag"."name" + FROM "posthog_taggeditem" + INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") + WHERE "posthog_taggeditem"."insight_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.11 + ''' + SELECT "posthog_sharingconfiguration"."id", + "posthog_sharingconfiguration"."team_id", + "posthog_sharingconfiguration"."dashboard_id", + "posthog_sharingconfiguration"."insight_id", + "posthog_sharingconfiguration"."recording_id", + "posthog_sharingconfiguration"."created_at", + "posthog_sharingconfiguration"."enabled", + "posthog_sharingconfiguration"."access_token" + FROM "posthog_sharingconfiguration" + WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.110 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -2755,7 +3346,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.101 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.111 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -2818,7 +3409,87 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.102 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.112 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.113 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.114 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -2850,7 +3521,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.103 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.115 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -2875,7 +3546,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.104 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.116 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -2938,7 +3609,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.105 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.117 ''' SELECT "posthog_dashboarditem"."id", "posthog_dashboarditem"."name", @@ -2973,7 +3644,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.106 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.118 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3043,7 +3714,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.107 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.119 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -3071,9 +3742,48 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.108 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.12 ''' - SELECT "posthog_team"."id", + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted", + "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags", + "posthog_team"."id", "posthog_team"."uuid", "posthog_team"."organization_id", "posthog_team"."project_id", @@ -3135,13 +3845,85 @@ "posthog_team"."event_properties_with_usage", "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 + "posthog_team"."external_data_workspace_last_synced_at", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in", + T6."id", + T6."password", + T6."last_login", + T6."first_name", + T6."last_name", + T6."is_staff", + T6."date_joined", + T6."uuid", + T6."current_organization_id", + T6."current_team_id", + T6."email", + T6."pending_email", + T6."temporary_token", + T6."distinct_id", + T6."is_email_verified", + T6."requested_password_reset_at", + T6."has_seen_product_intro_for", + T6."strapi_id", + T6."is_active", + T6."theme_mode", + T6."partial_notification_settings", + T6."anonymize_data", + T6."toolbar_mode", + T6."hedgehog_config", + T6."events_column_config", + T6."email_opt_in", + "posthog_text"."id", + "posthog_text"."body", + "posthog_text"."created_by_id", + "posthog_text"."last_modified_at", + "posthog_text"."last_modified_by_id", + "posthog_text"."team_id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_dashboardtile"."insight_id" = "posthog_dashboarditem"."id") + LEFT OUTER JOIN "posthog_team" ON ("posthog_dashboarditem"."team_id" = "posthog_team"."id") + LEFT OUTER JOIN "posthog_user" ON ("posthog_dashboarditem"."created_by_id" = "posthog_user"."id") + LEFT OUTER JOIN "posthog_user" T6 ON ("posthog_dashboarditem"."last_modified_by_id" = T6."id") + LEFT OUTER JOIN "posthog_text" ON ("posthog_dashboardtile"."text_id" = "posthog_text"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 99999 + AND NOT ("posthog_dashboard"."deleted" + AND "posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND (NOT "posthog_dashboarditem"."deleted" + OR "posthog_dashboardtile"."insight_id" IS NULL)) + ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.109 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.120 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3211,15 +3993,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.11 - ''' - SELECT "posthog_tag"."name" - FROM "posthog_taggeditem" - INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") - WHERE "posthog_taggeditem"."dashboard_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.110 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.121 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3275,14 +4049,84 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" WHERE "posthog_team"."id" = 99999 LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.111 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.122 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.123 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -3300,7 +4144,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.112 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.124 ''' SELECT "posthog_dashboarditem"."id", "posthog_dashboarditem"."name", @@ -3335,7 +4179,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.113 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.125 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -3359,7 +4203,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.114 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.126 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3429,7 +4273,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.115 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.127 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -3455,7 +4299,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.116 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.128 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -3481,7 +4325,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.117 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.129 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3544,7 +4388,15 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.118 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.13 + ''' + SELECT "posthog_tag"."name" + FROM "posthog_taggeditem" + INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") + WHERE "posthog_taggeditem"."dashboard_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.130 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -3569,7 +4421,7 @@ AND "posthog_dashboardtile"."insight_id" = 99999) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.119 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.131 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -3590,39 +4442,7 @@ AND "posthog_dashboardtile"."insight_id" = 99999) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.12 - ''' - SELECT "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_user" - WHERE "posthog_user"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.120 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.132 ''' SELECT "posthog_dashboardtile"."dashboard_id" FROM "posthog_dashboardtile" @@ -3633,7 +4453,7 @@ AND "posthog_dashboardtile"."insight_id" = 99999) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.121 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.133 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -3661,7 +4481,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.122 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.134 ''' SELECT "posthog_tag"."name" FROM "posthog_taggeditem" @@ -3669,7 +4489,7 @@ WHERE "posthog_taggeditem"."insight_id" = 99999 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.123 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.135 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -3701,7 +4521,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.124 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.136 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3764,7 +4584,87 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.125 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.137 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.138 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '60' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '60' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.139 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -3796,7 +4696,39 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.126 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.14 + ''' + SELECT "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in" + FROM "posthog_user" + WHERE "posthog_user"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.140 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -3850,7 +4782,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.127 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.141 ''' SELECT "posthog_sharingconfiguration"."id", "posthog_sharingconfiguration"."team_id", @@ -3868,7 +4800,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.128 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.142 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -4054,7 +4986,7 @@ ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.129 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.143 ''' SELECT "posthog_insightcachingstate"."id", "posthog_insightcachingstate"."team_id", @@ -4075,70 +5007,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.13 - ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.130 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.144 ''' SELECT ("posthog_dashboardtile"."insight_id") AS "_prefetch_related_val_insight_id", "posthog_dashboard"."id", @@ -4175,7 +5044,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.131 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.145 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -4200,7 +5069,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.132 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.146 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -4227,7 +5096,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.133 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.147 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -4414,7 +5283,7 @@ ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.134 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.148 ''' SELECT "posthog_insightcachingstate"."id", "posthog_insightcachingstate"."team_id", @@ -4435,7 +5304,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.135 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.149 ''' SELECT ("posthog_dashboardtile"."insight_id") AS "_prefetch_related_val_insight_id", "posthog_dashboard"."id", @@ -4472,7 +5341,70 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.136 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.15 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.150 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -4497,7 +5429,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.137 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.151 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -4524,7 +5456,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.138 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.152 ''' SELECT "posthog_taggeditem"."id", "posthog_taggeditem"."tag_id", @@ -4546,7 +5478,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.139 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.153 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -4574,39 +5506,7 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.14 - ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.140 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.154 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -4632,7 +5532,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.141 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.155 ''' SELECT "posthog_tag"."name" FROM "posthog_taggeditem" @@ -4640,477 +5540,87 @@ WHERE "posthog_taggeditem"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.15 - ''' - SELECT "posthog_dashboardtile"."id" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."dashboard_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.16 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.17 - ''' - SELECT COUNT(*) AS "__count" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."dashboard_id" = 99999 - AND NOT ("posthog_dashboardtile"."insight_id" IS NULL)) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.18 - ''' - SELECT "posthog_sharingconfiguration"."id", - "posthog_sharingconfiguration"."team_id", - "posthog_sharingconfiguration"."dashboard_id", - "posthog_sharingconfiguration"."insight_id", - "posthog_sharingconfiguration"."recording_id", - "posthog_sharingconfiguration"."created_at", - "posthog_sharingconfiguration"."enabled", - "posthog_sharingconfiguration"."access_token" - FROM "posthog_sharingconfiguration" - WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.19 - ''' - SELECT COUNT(*) AS "__count" - FROM "posthog_taggeditem" - WHERE "posthog_taggeditem"."dashboard_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.2 - ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.20 - ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.21 - ''' - SELECT "posthog_sharingconfiguration"."id", - "posthog_sharingconfiguration"."team_id", - "posthog_sharingconfiguration"."dashboard_id", - "posthog_sharingconfiguration"."insight_id", - "posthog_sharingconfiguration"."recording_id", - "posthog_sharingconfiguration"."created_at", - "posthog_sharingconfiguration"."enabled", - "posthog_sharingconfiguration"."access_token" - FROM "posthog_sharingconfiguration" - WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.22 - ''' - SELECT "posthog_dashboardtile"."id", - "posthog_dashboardtile"."dashboard_id", - "posthog_dashboardtile"."insight_id", - "posthog_dashboardtile"."text_id", - "posthog_dashboardtile"."layouts", - "posthog_dashboardtile"."color", - "posthog_dashboardtile"."filters_hash", - "posthog_dashboardtile"."last_refresh", - "posthog_dashboardtile"."refreshing", - "posthog_dashboardtile"."refresh_attempt", - "posthog_dashboardtile"."deleted", - "posthog_dashboarditem"."id", - "posthog_dashboarditem"."name", - "posthog_dashboarditem"."derived_name", - "posthog_dashboarditem"."description", - "posthog_dashboarditem"."team_id", - "posthog_dashboarditem"."filters", - "posthog_dashboarditem"."filters_hash", - "posthog_dashboarditem"."query", - "posthog_dashboarditem"."order", - "posthog_dashboarditem"."deleted", - "posthog_dashboarditem"."saved", - "posthog_dashboarditem"."created_at", - "posthog_dashboarditem"."refreshing", - "posthog_dashboarditem"."created_by_id", - "posthog_dashboarditem"."is_sample", - "posthog_dashboarditem"."short_id", - "posthog_dashboarditem"."favorited", - "posthog_dashboarditem"."refresh_attempt", - "posthog_dashboarditem"."last_modified_at", - "posthog_dashboarditem"."last_modified_by_id", - "posthog_dashboarditem"."dashboard_id", - "posthog_dashboarditem"."last_refresh", - "posthog_dashboarditem"."layouts", - "posthog_dashboarditem"."color", - "posthog_dashboarditem"."dive_dashboard_id", - "posthog_dashboarditem"."updated_at", - "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags", - "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in", - T6."id", - T6."password", - T6."last_login", - T6."first_name", - T6."last_name", - T6."is_staff", - T6."date_joined", - T6."uuid", - T6."current_organization_id", - T6."current_team_id", - T6."email", - T6."pending_email", - T6."temporary_token", - T6."distinct_id", - T6."is_email_verified", - T6."requested_password_reset_at", - T6."has_seen_product_intro_for", - T6."strapi_id", - T6."is_active", - T6."theme_mode", - T6."partial_notification_settings", - T6."anonymize_data", - T6."toolbar_mode", - T6."hedgehog_config", - T6."events_column_config", - T6."email_opt_in", - "posthog_text"."id", - "posthog_text"."body", - "posthog_text"."created_by_id", - "posthog_text"."last_modified_at", - "posthog_text"."last_modified_by_id", - "posthog_text"."team_id" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_dashboardtile"."insight_id" = "posthog_dashboarditem"."id") - LEFT OUTER JOIN "posthog_team" ON ("posthog_dashboarditem"."team_id" = "posthog_team"."id") - LEFT OUTER JOIN "posthog_user" ON ("posthog_dashboarditem"."created_by_id" = "posthog_user"."id") - LEFT OUTER JOIN "posthog_user" T6 ON ("posthog_dashboarditem"."last_modified_by_id" = T6."id") - LEFT OUTER JOIN "posthog_text" ON ("posthog_dashboardtile"."text_id" = "posthog_text"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."dashboard_id" = 99999 - AND NOT ("posthog_dashboard"."deleted" - AND "posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND (NOT "posthog_dashboarditem"."deleted" - OR "posthog_dashboardtile"."insight_id" IS NULL)) - ORDER BY "posthog_dashboarditem"."order" ASC - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.23 - ''' - SELECT "posthog_tag"."name" - FROM "posthog_taggeditem" - INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") - WHERE "posthog_taggeditem"."dashboard_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.24 - ''' - SELECT "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_user" - WHERE "posthog_user"."id" = 99999 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.16 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.25 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.17 ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.26 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.18 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -5142,57 +5652,111 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.27 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.19 ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" = 99999) + SELECT "posthog_dashboardtile"."id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.2 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.28 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.20 ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" = 99999) + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.29 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.21 + ''' + SELECT COUNT(*) AS "__count" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 99999 + AND NOT ("posthog_dashboardtile"."insight_id" IS NULL)) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.22 + ''' + SELECT "posthog_sharingconfiguration"."id", + "posthog_sharingconfiguration"."team_id", + "posthog_sharingconfiguration"."dashboard_id", + "posthog_sharingconfiguration"."insight_id", + "posthog_sharingconfiguration"."recording_id", + "posthog_sharingconfiguration"."created_at", + "posthog_sharingconfiguration"."enabled", + "posthog_sharingconfiguration"."access_token" + FROM "posthog_sharingconfiguration" + WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.23 + ''' + SELECT COUNT(*) AS "__count" + FROM "posthog_taggeditem" + WHERE "posthog_taggeditem"."dashboard_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.24 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -5248,6 +5812,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -5255,20 +5826,34 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.3 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.25 ''' - SELECT "posthog_dashboardtile"."id" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."dashboard_id" = 99999) + SELECT "posthog_sharingconfiguration"."id", + "posthog_sharingconfiguration"."team_id", + "posthog_sharingconfiguration"."dashboard_id", + "posthog_sharingconfiguration"."insight_id", + "posthog_sharingconfiguration"."recording_id", + "posthog_sharingconfiguration"."created_at", + "posthog_sharingconfiguration"."enabled", + "posthog_sharingconfiguration"."access_token" + FROM "posthog_sharingconfiguration" + WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.30 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.26 ''' - SELECT "posthog_dashboarditem"."id", + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted", + "posthog_dashboarditem"."id", "posthog_dashboarditem"."name", "posthog_dashboarditem"."derived_name", "posthog_dashboarditem"."description", @@ -5295,15 +5880,8 @@ "posthog_dashboarditem"."dive_dashboard_id", "posthog_dashboarditem"."updated_at", "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags" - FROM "posthog_dashboarditem" - WHERE "posthog_dashboarditem"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.31 - ''' - SELECT "posthog_team"."id", + "posthog_dashboarditem"."tags", + "posthog_team"."id", "posthog_team"."uuid", "posthog_team"."organization_id", "posthog_team"."project_id", @@ -5365,41 +5943,125 @@ "posthog_team"."event_properties_with_usage", "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 + "posthog_team"."external_data_workspace_last_synced_at", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in", + T6."id", + T6."password", + T6."last_login", + T6."first_name", + T6."last_name", + T6."is_staff", + T6."date_joined", + T6."uuid", + T6."current_organization_id", + T6."current_team_id", + T6."email", + T6."pending_email", + T6."temporary_token", + T6."distinct_id", + T6."is_email_verified", + T6."requested_password_reset_at", + T6."has_seen_product_intro_for", + T6."strapi_id", + T6."is_active", + T6."theme_mode", + T6."partial_notification_settings", + T6."anonymize_data", + T6."toolbar_mode", + T6."hedgehog_config", + T6."events_column_config", + T6."email_opt_in", + "posthog_text"."id", + "posthog_text"."body", + "posthog_text"."created_by_id", + "posthog_text"."last_modified_at", + "posthog_text"."last_modified_by_id", + "posthog_text"."team_id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + LEFT OUTER JOIN "posthog_dashboarditem" ON ("posthog_dashboardtile"."insight_id" = "posthog_dashboarditem"."id") + LEFT OUTER JOIN "posthog_team" ON ("posthog_dashboarditem"."team_id" = "posthog_team"."id") + LEFT OUTER JOIN "posthog_user" ON ("posthog_dashboarditem"."created_by_id" = "posthog_user"."id") + LEFT OUTER JOIN "posthog_user" T6 ON ("posthog_dashboarditem"."last_modified_by_id" = T6."id") + LEFT OUTER JOIN "posthog_text" ON ("posthog_dashboardtile"."text_id" = "posthog_text"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 99999 + AND NOT ("posthog_dashboard"."deleted" + AND "posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND (NOT "posthog_dashboarditem"."deleted" + OR "posthog_dashboardtile"."insight_id" IS NULL)) + ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.32 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.27 ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" IN (1, - 2, - 3, - 4, - 5 /* ... */)) + SELECT "posthog_tag"."name" + FROM "posthog_taggeditem" + INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") + WHERE "posthog_taggeditem"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.33 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.28 + ''' + SELECT "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in" + FROM "posthog_user" + WHERE "posthog_user"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.29 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -5455,13 +6117,6 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -5469,7 +6124,215 @@ LIMIT 21 ''' # --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.3 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.30 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.31 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.32 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.33 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" = 99999) + LIMIT 21 + ''' +# --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.34 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.35 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -5525,13 +6388,6 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -5539,7 +6395,42 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.35 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.36 + ''' + SELECT "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags" + FROM "posthog_dashboarditem" + WHERE "posthog_dashboarditem"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.37 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -5595,6 +6486,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -5602,59 +6500,6 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.36 - ''' - SELECT "posthog_dashboardtile"."id", - "posthog_dashboardtile"."dashboard_id", - "posthog_dashboardtile"."insight_id", - "posthog_dashboardtile"."text_id", - "posthog_dashboardtile"."layouts", - "posthog_dashboardtile"."color", - "posthog_dashboardtile"."filters_hash", - "posthog_dashboardtile"."last_refresh", - "posthog_dashboardtile"."refreshing", - "posthog_dashboardtile"."refresh_attempt", - "posthog_dashboardtile"."deleted" - FROM "posthog_dashboardtile" - WHERE "posthog_dashboardtile"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.37 - ''' - SELECT "posthog_dashboarditem"."id", - "posthog_dashboarditem"."name", - "posthog_dashboarditem"."derived_name", - "posthog_dashboarditem"."description", - "posthog_dashboarditem"."team_id", - "posthog_dashboarditem"."filters", - "posthog_dashboarditem"."filters_hash", - "posthog_dashboarditem"."query", - "posthog_dashboarditem"."order", - "posthog_dashboarditem"."deleted", - "posthog_dashboarditem"."saved", - "posthog_dashboarditem"."created_at", - "posthog_dashboarditem"."refreshing", - "posthog_dashboarditem"."created_by_id", - "posthog_dashboarditem"."is_sample", - "posthog_dashboarditem"."short_id", - "posthog_dashboarditem"."favorited", - "posthog_dashboarditem"."refresh_attempt", - "posthog_dashboarditem"."last_modified_at", - "posthog_dashboarditem"."last_modified_by_id", - "posthog_dashboarditem"."dashboard_id", - "posthog_dashboarditem"."last_refresh", - "posthog_dashboarditem"."layouts", - "posthog_dashboarditem"."color", - "posthog_dashboarditem"."dive_dashboard_id", - "posthog_dashboarditem"."updated_at", - "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags" - FROM "posthog_dashboarditem" - WHERE "posthog_dashboarditem"."id" = 99999 - LIMIT 21 - ''' -# --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.38 ''' SELECT "posthog_dashboard"."id", @@ -5675,8 +6520,12 @@ "posthog_dashboard"."share_token", "posthog_dashboard"."is_shared" FROM "posthog_dashboard" - WHERE "posthog_dashboard"."id" = 99999 - LIMIT 21 + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" IN (1, + 2, + 3, + 4, + 5 /* ... */)) ''' # --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.39 @@ -5751,7 +6600,13 @@ # --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.4 ''' - SELECT "posthog_organization"."id", + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", "posthog_organization"."name", "posthog_organization"."slug", "posthog_organization"."logo_media_id", @@ -5770,9 +6625,9 @@ "posthog_organization"."setup_section_2_completed", "posthog_organization"."personalization", "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.40 @@ -6017,97 +6872,45 @@ "posthog_team"."session_recording_event_trigger_config", "posthog_team"."session_replay_config", "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.46 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.47 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.48 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.46 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -6163,6 +6966,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -6170,144 +6980,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.49 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.5 - ''' - SELECT COUNT(*) AS "__count" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."dashboard_id" = 99999 - AND NOT ("posthog_dashboardtile"."insight_id" IS NULL)) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.50 - ''' - SELECT "posthog_dashboardtile"."id", - "posthog_dashboardtile"."dashboard_id", - "posthog_dashboardtile"."insight_id", - "posthog_dashboardtile"."text_id", - "posthog_dashboardtile"."layouts", - "posthog_dashboardtile"."color", - "posthog_dashboardtile"."filters_hash", - "posthog_dashboardtile"."last_refresh", - "posthog_dashboardtile"."refreshing", - "posthog_dashboardtile"."refresh_attempt", - "posthog_dashboardtile"."deleted" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.51 - ''' - SELECT "posthog_dashboardtile"."dashboard_id" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.52 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" IN (1, - 2, - 3, - 4, - 5 /* ... */)) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.53 - ''' - SELECT "posthog_tag"."name" - FROM "posthog_taggeditem" - INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") - WHERE "posthog_taggeditem"."insight_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.54 - ''' - SELECT "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_user" - WHERE "posthog_user"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.55 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.47 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -6370,39 +7043,71 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.56 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.48 ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted" + FROM "posthog_dashboardtile" + WHERE "posthog_dashboardtile"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.49 + ''' + SELECT "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags" + FROM "posthog_dashboarditem" + WHERE "posthog_dashboarditem"."id" = 99999 + LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.57 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.5 + ''' + SELECT "posthog_dashboardtile"."id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.50 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -6422,12 +7127,11 @@ "posthog_dashboard"."share_token", "posthog_dashboard"."is_shared" FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" = 99999) + WHERE "posthog_dashboard"."id" = 99999 LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.58 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.51 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -6483,6 +7187,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -6490,56 +7201,59 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.59 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.52 ''' - SELECT "posthog_dashboarditem"."id", - "posthog_dashboarditem"."name", - "posthog_dashboarditem"."derived_name", - "posthog_dashboarditem"."description", - "posthog_dashboarditem"."team_id", - "posthog_dashboarditem"."filters", - "posthog_dashboarditem"."filters_hash", - "posthog_dashboarditem"."query", - "posthog_dashboarditem"."order", - "posthog_dashboarditem"."deleted", - "posthog_dashboarditem"."saved", - "posthog_dashboarditem"."created_at", - "posthog_dashboarditem"."refreshing", - "posthog_dashboarditem"."created_by_id", - "posthog_dashboarditem"."is_sample", - "posthog_dashboarditem"."short_id", - "posthog_dashboarditem"."favorited", - "posthog_dashboarditem"."refresh_attempt", - "posthog_dashboarditem"."last_modified_at", - "posthog_dashboarditem"."last_modified_by_id", - "posthog_dashboarditem"."dashboard_id", - "posthog_dashboarditem"."last_refresh", - "posthog_dashboarditem"."layouts", - "posthog_dashboarditem"."color", - "posthog_dashboarditem"."dive_dashboard_id", - "posthog_dashboarditem"."updated_at", - "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags" - FROM "posthog_dashboarditem" - WHERE "posthog_dashboarditem"."id" = 99999 + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.6 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.53 ''' - SELECT "posthog_sharingconfiguration"."id", - "posthog_sharingconfiguration"."team_id", - "posthog_sharingconfiguration"."dashboard_id", - "posthog_sharingconfiguration"."insight_id", - "posthog_sharingconfiguration"."recording_id", - "posthog_sharingconfiguration"."created_at", - "posthog_sharingconfiguration"."enabled", - "posthog_sharingconfiguration"."access_token" - FROM "posthog_sharingconfiguration" - WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.60 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.54 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -6595,13 +7309,6 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -6609,35 +7316,158 @@ LIMIT 21 ''' # --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.55 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.56 + ''' + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.57 + ''' + SELECT "posthog_dashboardtile"."dashboard_id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.58 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" IN (1, + 2, + 3, + 4, + 5 /* ... */)) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.59 + ''' + SELECT "posthog_tag"."name" + FROM "posthog_taggeditem" + INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") + WHERE "posthog_taggeditem"."insight_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.6 + ''' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.60 + ''' + SELECT "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in" + FROM "posthog_user" + WHERE "posthog_user"."id" = 99999 + LIMIT 21 + ''' +# --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.61 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" IN (1, - 2, - 3, - 4, - 5 /* ... */)) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.62 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -6693,13 +7523,6 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -6707,77 +7530,144 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.63 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.62 ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) LIMIT 21 ''' # --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.63 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.64 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.65 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.66 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -6840,25 +7730,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.65 - ''' - SELECT "posthog_dashboardtile"."id", - "posthog_dashboardtile"."dashboard_id", - "posthog_dashboardtile"."insight_id", - "posthog_dashboardtile"."text_id", - "posthog_dashboardtile"."layouts", - "posthog_dashboardtile"."color", - "posthog_dashboardtile"."filters_hash", - "posthog_dashboardtile"."last_refresh", - "posthog_dashboardtile"."refreshing", - "posthog_dashboardtile"."refresh_attempt", - "posthog_dashboardtile"."deleted" - FROM "posthog_dashboardtile" - WHERE "posthog_dashboardtile"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.66 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.67 ''' SELECT "posthog_dashboarditem"."id", "posthog_dashboarditem"."name", @@ -6893,30 +7765,6 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.67 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - WHERE "posthog_dashboard"."id" = 99999 - LIMIT 21 - ''' -# --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.68 ''' SELECT "posthog_team"."id", @@ -6989,64 +7837,45 @@ # --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.69 ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" IN (1, + 2, + 3, + 4, + 5 /* ... */)) ''' # --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.7 ''' SELECT COUNT(*) AS "__count" - FROM "posthog_taggeditem" - WHERE "posthog_taggeditem"."dashboard_id" = 99999 + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 99999 + AND NOT ("posthog_dashboardtile"."insight_id" IS NULL)) ''' # --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.70 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.71 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7102,6 +7931,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -7109,132 +7945,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.72 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.73 - ''' - SELECT "posthog_dashboardtile"."id", - "posthog_dashboardtile"."dashboard_id", - "posthog_dashboardtile"."insight_id", - "posthog_dashboardtile"."text_id", - "posthog_dashboardtile"."layouts", - "posthog_dashboardtile"."color", - "posthog_dashboardtile"."filters_hash", - "posthog_dashboardtile"."last_refresh", - "posthog_dashboardtile"."refreshing", - "posthog_dashboardtile"."refresh_attempt", - "posthog_dashboardtile"."deleted" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.74 - ''' - SELECT "posthog_dashboardtile"."dashboard_id" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.75 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" IN (1, - 2, - 3, - 4, - 5 /* ... */)) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.76 - ''' - SELECT "posthog_tag"."name" - FROM "posthog_taggeditem" - INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") - WHERE "posthog_taggeditem"."insight_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.77 - ''' - SELECT "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_user" - WHERE "posthog_user"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.78 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.71 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7290,46 +8001,21 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.79 - ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + WHERE "posthog_team"."id" = 99999 + LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.8 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.72 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7385,13 +8071,6 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -7399,7 +8078,60 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.80 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.73 + ''' + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted" + FROM "posthog_dashboardtile" + WHERE "posthog_dashboardtile"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.74 + ''' + SELECT "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags" + FROM "posthog_dashboarditem" + WHERE "posthog_dashboarditem"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.75 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -7419,12 +8151,11 @@ "posthog_dashboard"."share_token", "posthog_dashboard"."is_shared" FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" = 99999) + WHERE "posthog_dashboard"."id" = 99999 LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.81 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.76 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7480,6 +8211,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -7487,42 +8225,59 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.82 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.77 ''' - SELECT "posthog_dashboarditem"."id", - "posthog_dashboarditem"."name", - "posthog_dashboarditem"."derived_name", - "posthog_dashboarditem"."description", - "posthog_dashboarditem"."team_id", - "posthog_dashboarditem"."filters", - "posthog_dashboarditem"."filters_hash", - "posthog_dashboarditem"."query", - "posthog_dashboarditem"."order", - "posthog_dashboarditem"."deleted", - "posthog_dashboarditem"."saved", - "posthog_dashboarditem"."created_at", - "posthog_dashboarditem"."refreshing", - "posthog_dashboarditem"."created_by_id", - "posthog_dashboarditem"."is_sample", - "posthog_dashboarditem"."short_id", - "posthog_dashboarditem"."favorited", - "posthog_dashboarditem"."refresh_attempt", - "posthog_dashboarditem"."last_modified_at", - "posthog_dashboarditem"."last_modified_by_id", - "posthog_dashboarditem"."dashboard_id", - "posthog_dashboarditem"."last_refresh", - "posthog_dashboarditem"."layouts", - "posthog_dashboarditem"."color", - "posthog_dashboarditem"."dive_dashboard_id", - "posthog_dashboarditem"."updated_at", - "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags" - FROM "posthog_dashboarditem" - WHERE "posthog_dashboarditem"."id" = 99999 + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.83 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.78 + ''' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.79 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7578,13 +8333,6 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -7592,7 +8340,78 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.84 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.8 + ''' + SELECT "posthog_sharingconfiguration"."id", + "posthog_sharingconfiguration"."team_id", + "posthog_sharingconfiguration"."dashboard_id", + "posthog_sharingconfiguration"."insight_id", + "posthog_sharingconfiguration"."recording_id", + "posthog_sharingconfiguration"."created_at", + "posthog_sharingconfiguration"."enabled", + "posthog_sharingconfiguration"."access_token" + FROM "posthog_sharingconfiguration" + WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.80 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.81 + ''' + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.82 + ''' + SELECT "posthog_dashboardtile"."dashboard_id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."insight_id" = 99999) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.83 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -7620,7 +8439,47 @@ 5 /* ... */)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.85 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.84 + ''' + SELECT "posthog_tag"."name" + FROM "posthog_taggeditem" + INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") + WHERE "posthog_taggeditem"."insight_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.85 + ''' + SELECT "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in" + FROM "posthog_user" + WHERE "posthog_user"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.86 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7676,13 +8535,6 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -7690,7 +8542,151 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.86 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.87 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.88 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'insight' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.89 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.9 + ''' + SELECT COUNT(*) AS "__count" + FROM "posthog_taggeditem" + WHERE "posthog_taggeditem"."dashboard_id" = 99999 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.90 + ''' + SELECT "posthog_dashboard"."id", + "posthog_dashboard"."name", + "posthog_dashboard"."description", + "posthog_dashboard"."team_id", + "posthog_dashboard"."pinned", + "posthog_dashboard"."created_at", + "posthog_dashboard"."created_by_id", + "posthog_dashboard"."deleted", + "posthog_dashboard"."last_accessed_at", + "posthog_dashboard"."filters", + "posthog_dashboard"."variables", + "posthog_dashboard"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.91 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7746,13 +8742,6 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -7760,7 +8749,42 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.87 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.92 + ''' + SELECT "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags" + FROM "posthog_dashboarditem" + WHERE "posthog_dashboarditem"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.93 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7816,6 +8840,13 @@ "posthog_team"."modifiers", "posthog_team"."correlation_config", "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", "posthog_team"."external_data_workspace_id", "posthog_team"."external_data_workspace_last_synced_at" FROM "posthog_team" @@ -7823,74 +8854,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.88 - ''' - SELECT "posthog_dashboardtile"."id", - "posthog_dashboardtile"."dashboard_id", - "posthog_dashboardtile"."insight_id", - "posthog_dashboardtile"."text_id", - "posthog_dashboardtile"."layouts", - "posthog_dashboardtile"."color", - "posthog_dashboardtile"."filters_hash", - "posthog_dashboardtile"."last_refresh", - "posthog_dashboardtile"."refreshing", - "posthog_dashboardtile"."refresh_attempt", - "posthog_dashboardtile"."deleted" - FROM "posthog_dashboardtile" - WHERE "posthog_dashboardtile"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.89 - ''' - SELECT "posthog_dashboarditem"."id", - "posthog_dashboarditem"."name", - "posthog_dashboarditem"."derived_name", - "posthog_dashboarditem"."description", - "posthog_dashboarditem"."team_id", - "posthog_dashboarditem"."filters", - "posthog_dashboarditem"."filters_hash", - "posthog_dashboarditem"."query", - "posthog_dashboarditem"."order", - "posthog_dashboarditem"."deleted", - "posthog_dashboarditem"."saved", - "posthog_dashboarditem"."created_at", - "posthog_dashboarditem"."refreshing", - "posthog_dashboarditem"."created_by_id", - "posthog_dashboarditem"."is_sample", - "posthog_dashboarditem"."short_id", - "posthog_dashboarditem"."favorited", - "posthog_dashboarditem"."refresh_attempt", - "posthog_dashboarditem"."last_modified_at", - "posthog_dashboarditem"."last_modified_by_id", - "posthog_dashboarditem"."dashboard_id", - "posthog_dashboarditem"."last_refresh", - "posthog_dashboarditem"."layouts", - "posthog_dashboarditem"."color", - "posthog_dashboarditem"."dive_dashboard_id", - "posthog_dashboarditem"."updated_at", - "posthog_dashboarditem"."deprecated_tags", - "posthog_dashboarditem"."tags" - FROM "posthog_dashboarditem" - WHERE "posthog_dashboarditem"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.9 - ''' - SELECT "posthog_sharingconfiguration"."id", - "posthog_sharingconfiguration"."team_id", - "posthog_sharingconfiguration"."dashboard_id", - "posthog_sharingconfiguration"."insight_id", - "posthog_sharingconfiguration"."recording_id", - "posthog_sharingconfiguration"."created_at", - "posthog_sharingconfiguration"."enabled", - "posthog_sharingconfiguration"."access_token" - FROM "posthog_sharingconfiguration" - WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.90 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.94 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -7910,11 +8874,15 @@ "posthog_dashboard"."share_token", "posthog_dashboard"."is_shared" FROM "posthog_dashboard" - WHERE "posthog_dashboard"."id" = 99999 - LIMIT 21 + WHERE (NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboard"."id" IN (1, + 2, + 3, + 4, + 5 /* ... */)) ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.91 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.95 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7984,59 +8952,77 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.92 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.93 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.96 ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.94 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.97 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -8099,32 +9085,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.95 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - INNER JOIN "posthog_dashboardtile" ON ("posthog_dashboard"."id" = "posthog_dashboardtile"."dashboard_id") - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.96 +# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.98 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -8138,58 +9099,43 @@ "posthog_dashboardtile"."refresh_attempt", "posthog_dashboardtile"."deleted" FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.97 - ''' - SELECT "posthog_dashboardtile"."dashboard_id" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."insight_id" = 99999) - ''' -# --- -# name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.98 - ''' - SELECT "posthog_dashboard"."id", - "posthog_dashboard"."name", - "posthog_dashboard"."description", - "posthog_dashboard"."team_id", - "posthog_dashboard"."pinned", - "posthog_dashboard"."created_at", - "posthog_dashboard"."created_by_id", - "posthog_dashboard"."deleted", - "posthog_dashboard"."last_accessed_at", - "posthog_dashboard"."filters", - "posthog_dashboard"."variables", - "posthog_dashboard"."creation_mode", - "posthog_dashboard"."restriction_level", - "posthog_dashboard"."deprecated_tags", - "posthog_dashboard"."tags", - "posthog_dashboard"."share_token", - "posthog_dashboard"."is_shared" - FROM "posthog_dashboard" - WHERE (NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboard"."id" IN (1, - 2, - 3, - 4, - 5 /* ... */)) + WHERE "posthog_dashboardtile"."id" = 99999 + LIMIT 21 ''' # --- # name: TestDashboard.test_loading_individual_dashboard_does_not_prefetch_all_possible_tiles.99 ''' - SELECT "posthog_tag"."name" - FROM "posthog_taggeditem" - INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") - WHERE "posthog_taggeditem"."insight_id" = 99999 + SELECT "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags" + FROM "posthog_dashboarditem" + WHERE "posthog_dashboarditem"."id" = 99999 + LIMIT 21 ''' # --- # name: TestDashboard.test_retrieve_dashboard @@ -8235,6 +9181,40 @@ LIMIT 21 ''' # --- +# name: TestDashboard.test_retrieve_dashboard.10 + ''' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard.11 + ''' + SELECT "posthog_tag"."name" + FROM "posthog_taggeditem" + INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") + WHERE "posthog_taggeditem"."dashboard_id" = 99999 + ''' +# --- # name: TestDashboard.test_retrieve_dashboard.2 ''' SELECT "posthog_team"."id", @@ -8327,10 +9307,90 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- # name: TestDashboard.test_retrieve_dashboard.4 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '67' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '67' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard.5 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard.6 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -8384,7 +9444,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard.5 +# name: TestDashboard.test_retrieve_dashboard.7 ''' SELECT "posthog_sharingconfiguration"."id", "posthog_sharingconfiguration"."team_id", @@ -8402,7 +9462,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_retrieve_dashboard.6 +# name: TestDashboard.test_retrieve_dashboard.8 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -8588,7 +9648,7 @@ ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_retrieve_dashboard.7 +# name: TestDashboard.test_retrieve_dashboard.9 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -8775,40 +9835,6 @@ ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_retrieve_dashboard.8 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_retrieve_dashboard.9 - ''' - SELECT "posthog_tag"."name" - FROM "posthog_taggeditem" - INNER JOIN "posthog_tag" ON ("posthog_taggeditem"."tag_id" = "posthog_tag"."id") - WHERE "posthog_taggeditem"."dashboard_id" = 99999 - ''' -# --- # name: TestDashboard.test_retrieve_dashboard_list ''' SELECT "posthog_user"."id", @@ -8905,6 +9931,90 @@ ''' # --- # name: TestDashboard.test_retrieve_dashboard_list.10 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.11 + ''' + SELECT "posthog_sharingconfiguration"."id", + "posthog_sharingconfiguration"."team_id", + "posthog_sharingconfiguration"."dashboard_id", + "posthog_sharingconfiguration"."insight_id", + "posthog_sharingconfiguration"."recording_id", + "posthog_sharingconfiguration"."created_at", + "posthog_sharingconfiguration"."enabled", + "posthog_sharingconfiguration"."access_token" + FROM "posthog_sharingconfiguration" + WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.12 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -9085,7 +10195,7 @@ ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.11 +# name: TestDashboard.test_retrieve_dashboard_list.13 ''' SELECT "posthog_tag"."name" FROM "posthog_taggeditem" @@ -9093,7 +10203,7 @@ WHERE "posthog_taggeditem"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.12 +# name: TestDashboard.test_retrieve_dashboard_list.14 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -9125,7 +10235,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.13 +# name: TestDashboard.test_retrieve_dashboard_list.15 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -9188,7 +10298,130 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.14 +# name: TestDashboard.test_retrieve_dashboard_list.16 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.17 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.18 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.19 + ''' + SELECT "posthog_dashboardtile"."id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 99999) + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.2 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -9217,21 +10450,12 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestDashboard.test_retrieve_dashboard_list.15 - ''' - SELECT "posthog_dashboardtile"."id" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."dashboard_id" = 99999) + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.16 +# name: TestDashboard.test_retrieve_dashboard_list.20 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -9257,7 +10481,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.17 +# name: TestDashboard.test_retrieve_dashboard_list.21 ''' SELECT COUNT(*) AS "__count" FROM "posthog_dashboardtile" @@ -9269,7 +10493,7 @@ AND NOT ("posthog_dashboardtile"."insight_id" IS NULL)) ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.18 +# name: TestDashboard.test_retrieve_dashboard_list.22 ''' SELECT "posthog_sharingconfiguration"."id", "posthog_sharingconfiguration"."team_id", @@ -9283,46 +10507,14 @@ WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.19 +# name: TestDashboard.test_retrieve_dashboard_list.23 ''' SELECT COUNT(*) AS "__count" FROM "posthog_taggeditem" WHERE "posthog_taggeditem"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.2 - ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestDashboard.test_retrieve_dashboard_list.20 +# name: TestDashboard.test_retrieve_dashboard_list.24 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -9392,7 +10584,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.21 +# name: TestDashboard.test_retrieve_dashboard_list.25 ''' SELECT "posthog_sharingconfiguration"."id", "posthog_sharingconfiguration"."team_id", @@ -9406,7 +10598,7 @@ WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.22 +# name: TestDashboard.test_retrieve_dashboard_list.26 ''' SELECT "posthog_dashboardtile"."id", "posthog_dashboardtile"."dashboard_id", @@ -9587,7 +10779,7 @@ ORDER BY "posthog_dashboarditem"."order" ASC ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.23 +# name: TestDashboard.test_retrieve_dashboard_list.27 ''' SELECT "posthog_tag"."name" FROM "posthog_taggeditem" @@ -9595,7 +10787,7 @@ WHERE "posthog_taggeditem"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.24 +# name: TestDashboard.test_retrieve_dashboard_list.28 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -9627,7 +10819,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.25 +# name: TestDashboard.test_retrieve_dashboard_list.29 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -9690,7 +10882,133 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.26 +# name: TestDashboard.test_retrieve_dashboard_list.3 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.30 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.31 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '76' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.32 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -9722,7 +11040,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.27 +# name: TestDashboard.test_retrieve_dashboard_list.33 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -9748,7 +11066,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.28 +# name: TestDashboard.test_retrieve_dashboard_list.34 ''' SELECT COUNT(*) AS "__count" FROM "posthog_dashboard" @@ -9757,7 +11075,7 @@ AND NOT ("posthog_dashboard"."deleted")) ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.29 +# name: TestDashboard.test_retrieve_dashboard_list.35 ''' SELECT "posthog_dashboard"."id", "posthog_dashboard"."name", @@ -9812,18 +11130,7 @@ LIMIT 100 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.3 - ''' - SELECT "posthog_dashboardtile"."id" - FROM "posthog_dashboardtile" - INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") - WHERE (NOT ("posthog_dashboardtile"."deleted" - AND "posthog_dashboardtile"."deleted" IS NOT NULL) - AND NOT ("posthog_dashboard"."deleted") - AND "posthog_dashboardtile"."dashboard_id" = 99999) - ''' -# --- -# name: TestDashboard.test_retrieve_dashboard_list.30 +# name: TestDashboard.test_retrieve_dashboard_list.36 ''' SELECT "posthog_sharingconfiguration"."id", "posthog_sharingconfiguration"."team_id", @@ -9841,7 +11148,7 @@ 5 /* ... */) ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.31 +# name: TestDashboard.test_retrieve_dashboard_list.37 ''' SELECT "posthog_taggeditem"."id", "posthog_taggeditem"."tag_id", @@ -9863,7 +11170,86 @@ 5 /* ... */) ''' # --- +# name: TestDashboard.test_retrieve_dashboard_list.38 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '69' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '69' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '70' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'dashboard' + AND "ee_accesscontrol"."resource_id" = '70' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- # name: TestDashboard.test_retrieve_dashboard_list.4 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.5 + ''' + SELECT "posthog_dashboardtile"."id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 99999) + ''' +# --- +# name: TestDashboard.test_retrieve_dashboard_list.6 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -9889,7 +11275,7 @@ LIMIT 21 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.5 +# name: TestDashboard.test_retrieve_dashboard_list.7 ''' SELECT COUNT(*) AS "__count" FROM "posthog_dashboardtile" @@ -9901,7 +11287,7 @@ AND NOT ("posthog_dashboardtile"."insight_id" IS NULL)) ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.6 +# name: TestDashboard.test_retrieve_dashboard_list.8 ''' SELECT "posthog_sharingconfiguration"."id", "posthog_sharingconfiguration"."team_id", @@ -9915,94 +11301,10 @@ WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.7 +# name: TestDashboard.test_retrieve_dashboard_list.9 ''' SELECT COUNT(*) AS "__count" FROM "posthog_taggeditem" WHERE "posthog_taggeditem"."dashboard_id" = 99999 ''' # --- -# name: TestDashboard.test_retrieve_dashboard_list.8 - ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestDashboard.test_retrieve_dashboard_list.9 - ''' - SELECT "posthog_sharingconfiguration"."id", - "posthog_sharingconfiguration"."team_id", - "posthog_sharingconfiguration"."dashboard_id", - "posthog_sharingconfiguration"."insight_id", - "posthog_sharingconfiguration"."recording_id", - "posthog_sharingconfiguration"."created_at", - "posthog_sharingconfiguration"."enabled", - "posthog_sharingconfiguration"."access_token" - FROM "posthog_sharingconfiguration" - WHERE "posthog_sharingconfiguration"."dashboard_id" = 99999 - ''' -# --- diff --git a/posthog/api/test/dashboards/test_dashboard.py b/posthog/api/test/dashboards/test_dashboard.py index ef97a1e6bd64b..ee802318db349 100644 --- a/posthog/api/test/dashboards/test_dashboard.py +++ b/posthog/api/test/dashboards/test_dashboard.py @@ -267,19 +267,21 @@ def test_adding_insights_is_not_nplus1_for_gets(self): "insight": "TRENDS", } - with self.assertNumQueries(11): + baseline = 3 + + with self.assertNumQueries(baseline + 10): self.dashboard_api.get_dashboard(dashboard_id, query_params={"no_items_field": "true"}) self.dashboard_api.create_insight({"filters": filter_dict, "dashboards": [dashboard_id]}) - with self.assertNumQueries(21): + with self.assertNumQueries(baseline + 10 + 10): self.dashboard_api.get_dashboard(dashboard_id, query_params={"no_items_field": "true"}) self.dashboard_api.create_insight({"filters": filter_dict, "dashboards": [dashboard_id]}) - with self.assertNumQueries(21): + with self.assertNumQueries(baseline + 10 + 10): self.dashboard_api.get_dashboard(dashboard_id, query_params={"no_items_field": "true"}) self.dashboard_api.create_insight({"filters": filter_dict, "dashboards": [dashboard_id]}) - with self.assertNumQueries(21): + with self.assertNumQueries(baseline + 10 + 10): self.dashboard_api.get_dashboard(dashboard_id, query_params={"no_items_field": "true"}) @snapshot_postgres_queries @@ -296,7 +298,7 @@ def test_listing_dashboards_is_not_nplus1(self) -> None: ) self.client.force_login(user_with_collaboration) - with self.assertNumQueries(7): + with self.assertNumQueries(9): self.dashboard_api.list_dashboards() for i in range(5): @@ -304,7 +306,7 @@ def test_listing_dashboards_is_not_nplus1(self) -> None: for j in range(3): self.dashboard_api.create_insight({"dashboards": [dashboard_id], "name": f"insight-{j}"}) - with self.assertNumQueries(FuzzyInt(8, 9)): + with self.assertNumQueries(FuzzyInt(10, 11)): self.dashboard_api.list_dashboards(query_params={"limit": 300}) def test_listing_dashboards_does_not_include_tiles(self) -> None: @@ -1339,6 +1341,7 @@ def test_create_from_template_json_can_provide_query_tile(self) -> None: "tags": [], "timezone": None, "updated_at": ANY, + "user_access_level": "editor", "hogql": ANY, "types": ANY, }, diff --git a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr index 2105778e1cfba..6527545701a76 100644 --- a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr +++ b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr @@ -95,6 +95,262 @@ ''' # --- # name: TestNotebooks.test_updates_notebook.10 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '83' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '83' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestNotebooks.test_updates_notebook.11 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.12 + ''' + SELECT "posthog_notebook"."id", + "posthog_notebook"."short_id", + "posthog_notebook"."team_id", + "posthog_notebook"."title", + "posthog_notebook"."content", + "posthog_notebook"."text_content", + "posthog_notebook"."deleted", + "posthog_notebook"."version", + "posthog_notebook"."created_at", + "posthog_notebook"."created_by_id", + "posthog_notebook"."last_modified_at", + "posthog_notebook"."last_modified_by_id", + "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in", + T5."id", + T5."password", + T5."last_login", + T5."first_name", + T5."last_name", + T5."is_staff", + T5."date_joined", + T5."uuid", + T5."current_organization_id", + T5."current_team_id", + T5."email", + T5."pending_email", + T5."temporary_token", + T5."distinct_id", + T5."is_email_verified", + T5."requested_password_reset_at", + T5."has_seen_product_intro_for", + T5."strapi_id", + T5."is_active", + T5."theme_mode", + T5."partial_notification_settings", + T5."anonymize_data", + T5."toolbar_mode", + T5."hedgehog_config", + T5."events_column_config", + T5."email_opt_in" + FROM "posthog_notebook" + INNER JOIN "posthog_team" ON ("posthog_notebook"."team_id" = "posthog_team"."id") + LEFT OUTER JOIN "posthog_user" ON ("posthog_notebook"."created_by_id" = "posthog_user"."id") + LEFT OUTER JOIN "posthog_user" T5 ON ("posthog_notebook"."last_modified_by_id" = T5."id") + WHERE ("posthog_team"."project_id" = 99999 + AND "posthog_notebook"."short_id" = '00000000') + LIMIT 21 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.13 + ''' + SELECT "posthog_notebook"."id", + "posthog_notebook"."short_id", + "posthog_notebook"."team_id", + "posthog_notebook"."title", + "posthog_notebook"."content", + "posthog_notebook"."text_content", + "posthog_notebook"."deleted", + "posthog_notebook"."version", + "posthog_notebook"."created_at", + "posthog_notebook"."created_by_id", + "posthog_notebook"."last_modified_at", + "posthog_notebook"."last_modified_by_id" + FROM "posthog_notebook" + WHERE "posthog_notebook"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.14 + ''' + SELECT "posthog_notebook"."id", + "posthog_notebook"."short_id", + "posthog_notebook"."team_id", + "posthog_notebook"."title", + "posthog_notebook"."content", + "posthog_notebook"."text_content", + "posthog_notebook"."deleted", + "posthog_notebook"."version", + "posthog_notebook"."created_at", + "posthog_notebook"."created_by_id", + "posthog_notebook"."last_modified_at", + "posthog_notebook"."last_modified_by_id" + FROM "posthog_notebook" + WHERE "posthog_notebook"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + FOR + UPDATE + ''' +# --- +# name: TestNotebooks.test_updates_notebook.15 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -111,6 +367,7 @@ "posthog_user"."temporary_token", "posthog_user"."distinct_id", "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", "posthog_user"."has_seen_product_intro_for", "posthog_user"."strapi_id", "posthog_user"."is_active", @@ -126,7 +383,39 @@ LIMIT 21 ''' # --- -# name: TestNotebooks.test_updates_notebook.11 +# name: TestNotebooks.test_updates_notebook.16 + ''' + SELECT "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in" + FROM "posthog_user" + WHERE "posthog_user"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.17 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -189,7 +478,19 @@ LIMIT 21 ''' # --- -# name: TestNotebooks.test_updates_notebook.12 +# name: TestNotebooks.test_updates_notebook.18 + ''' + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.19 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -218,84 +519,110 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- -# name: TestNotebooks.test_updates_notebook.13 +# name: TestNotebooks.test_updates_notebook.2 ''' - SELECT COUNT(*) AS "__count" - FROM "posthog_activitylog" - WHERE ("posthog_activitylog"."scope" = 'Notebook' - AND "posthog_activitylog"."team_id" = 99999) + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 ''' # --- -# name: TestNotebooks.test_updates_notebook.14 - ''' - SELECT "posthog_activitylog"."id", - "posthog_activitylog"."team_id", - "posthog_activitylog"."organization_id", - "posthog_activitylog"."user_id", - "posthog_activitylog"."was_impersonated", - "posthog_activitylog"."is_system", - "posthog_activitylog"."activity", - "posthog_activitylog"."item_id", - "posthog_activitylog"."scope", - "posthog_activitylog"."detail", - "posthog_activitylog"."created_at", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_activitylog" - LEFT OUTER JOIN "posthog_user" ON ("posthog_activitylog"."user_id" = "posthog_user"."id") - WHERE ("posthog_activitylog"."scope" = 'Notebook' - AND "posthog_activitylog"."team_id" = 99999) - ORDER BY "posthog_activitylog"."created_at" DESC - LIMIT 2 +# name: TestNotebooks.test_updates_notebook.20 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '83' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '83' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) ''' # --- -# name: TestNotebooks.test_updates_notebook.15 +# name: TestNotebooks.test_updates_notebook.21 ''' - SELECT "posthog_instancesetting"."id", - "posthog_instancesetting"."key", - "posthog_instancesetting"."raw_value" - FROM "posthog_instancesetting" - WHERE "posthog_instancesetting"."key" = 'constance:posthog:RATE_LIMIT_ENABLED' - ORDER BY "posthog_instancesetting"."id" ASC - LIMIT 1 + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestNotebooks.test_updates_notebook.16 +# name: TestNotebooks.test_updates_notebook.22 ''' SELECT COUNT(*) AS "__count" FROM "posthog_activitylog" WHERE ("posthog_activitylog"."scope" = 'Notebook' - AND "posthog_activitylog"."team_id" = 2) + AND "posthog_activitylog"."team_id" = 99999) ''' # --- -# name: TestNotebooks.test_updates_notebook.17 +# name: TestNotebooks.test_updates_notebook.23 ''' SELECT "posthog_activitylog"."id", "posthog_activitylog"."team_id", @@ -314,7 +641,6 @@ "posthog_user"."first_name", "posthog_user"."last_name", "posthog_user"."is_staff", - "posthog_user"."is_active", "posthog_user"."date_joined", "posthog_user"."uuid", "posthog_user"."current_organization_id", @@ -327,21 +653,103 @@ "posthog_user"."requested_password_reset_at", "posthog_user"."has_seen_product_intro_for", "posthog_user"."strapi_id", + "posthog_user"."is_active", "posthog_user"."theme_mode", "posthog_user"."partial_notification_settings", "posthog_user"."anonymize_data", "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", "posthog_user"."events_column_config", "posthog_user"."email_opt_in" FROM "posthog_activitylog" LEFT OUTER JOIN "posthog_user" ON ("posthog_activitylog"."user_id" = "posthog_user"."id") WHERE ("posthog_activitylog"."scope" = 'Notebook' - AND "posthog_activitylog"."team_id" = 2) + AND "posthog_activitylog"."team_id" = 99999) ORDER BY "posthog_activitylog"."created_at" DESC LIMIT 2 ''' # --- -# name: TestNotebooks.test_updates_notebook.2 +# name: TestNotebooks.test_updates_notebook.3 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.4 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '83' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '83' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestNotebooks.test_updates_notebook.5 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -373,7 +781,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestNotebooks.test_updates_notebook.3 +# name: TestNotebooks.test_updates_notebook.6 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -405,7 +813,7 @@ LIMIT 21 ''' # --- -# name: TestNotebooks.test_updates_notebook.4 +# name: TestNotebooks.test_updates_notebook.7 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -468,7 +876,19 @@ LIMIT 21 ''' # --- -# name: TestNotebooks.test_updates_notebook.5 +# name: TestNotebooks.test_updates_notebook.8 + ''' + SELECT "posthog_project"."id", + "posthog_project"."organization_id", + "posthog_project"."name", + "posthog_project"."created_at", + "posthog_project"."product_description" + FROM "posthog_project" + WHERE "posthog_project"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.9 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -497,217 +917,8 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestNotebooks.test_updates_notebook.6 - ''' - SELECT "posthog_notebook"."id", - "posthog_notebook"."short_id", - "posthog_notebook"."team_id", - "posthog_notebook"."title", - "posthog_notebook"."content", - "posthog_notebook"."text_content", - "posthog_notebook"."deleted", - "posthog_notebook"."version", - "posthog_notebook"."created_at", - "posthog_notebook"."created_by_id", - "posthog_notebook"."last_modified_at", - "posthog_notebook"."last_modified_by_id", - "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in", - T5."id", - T5."password", - T5."last_login", - T5."first_name", - T5."last_name", - T5."is_staff", - T5."date_joined", - T5."uuid", - T5."current_organization_id", - T5."current_team_id", - T5."email", - T5."pending_email", - T5."temporary_token", - T5."distinct_id", - T5."is_email_verified", - T5."requested_password_reset_at", - T5."has_seen_product_intro_for", - T5."strapi_id", - T5."is_active", - T5."theme_mode", - T5."partial_notification_settings", - T5."anonymize_data", - T5."toolbar_mode", - T5."hedgehog_config", - T5."events_column_config", - T5."email_opt_in" - FROM "posthog_notebook" - INNER JOIN "posthog_team" ON ("posthog_notebook"."team_id" = "posthog_team"."id") - LEFT OUTER JOIN "posthog_user" ON ("posthog_notebook"."created_by_id" = "posthog_user"."id") - LEFT OUTER JOIN "posthog_user" T5 ON ("posthog_notebook"."last_modified_by_id" = T5."id") - WHERE ("posthog_team"."project_id" = 99999 - AND "posthog_notebook"."short_id" = '00000000') - LIMIT 21 - ''' -# --- -# name: TestNotebooks.test_updates_notebook.7 - ''' - SELECT "posthog_notebook"."id", - "posthog_notebook"."short_id", - "posthog_notebook"."team_id", - "posthog_notebook"."title", - "posthog_notebook"."content", - "posthog_notebook"."text_content", - "posthog_notebook"."deleted", - "posthog_notebook"."version", - "posthog_notebook"."created_at", - "posthog_notebook"."created_by_id", - "posthog_notebook"."last_modified_at", - "posthog_notebook"."last_modified_by_id" - FROM "posthog_notebook" - WHERE "posthog_notebook"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestNotebooks.test_updates_notebook.8 - ''' - SELECT "posthog_notebook"."id", - "posthog_notebook"."short_id", - "posthog_notebook"."team_id", - "posthog_notebook"."title", - "posthog_notebook"."content", - "posthog_notebook"."text_content", - "posthog_notebook"."deleted", - "posthog_notebook"."version", - "posthog_notebook"."created_at", - "posthog_notebook"."created_by_id", - "posthog_notebook"."last_modified_at", - "posthog_notebook"."last_modified_by_id" - FROM "posthog_notebook" - WHERE "posthog_notebook"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - FOR - UPDATE - ''' -# --- -# name: TestNotebooks.test_updates_notebook.9 - ''' - SELECT "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_user" - WHERE "posthog_user"."id" = 99999 + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) LIMIT 21 ''' # --- diff --git a/posthog/api/test/notebooks/test_notebook.py b/posthog/api/test/notebooks/test_notebook.py index f01d8fd6bc694..c3fa82861d949 100644 --- a/posthog/api/test/notebooks/test_notebook.py +++ b/posthog/api/test/notebooks/test_notebook.py @@ -95,6 +95,7 @@ def test_create_a_notebook(self, _, content: dict | None, text_content: str | No "deleted": False, "last_modified_at": mock.ANY, "last_modified_by": response.json()["last_modified_by"], + "user_access_level": "editor", } self.assert_notebook_activity( diff --git a/posthog/api/test/test_action.py b/posthog/api/test/test_action.py index 3a55bb84f9db5..fb0034e69b758 100644 --- a/posthog/api/test/test_action.py +++ b/posthog/api/test/test_action.py @@ -261,7 +261,7 @@ def test_update_action(self, patch_capture, *args): ) # test queries - with self.assertNumQueries(FuzzyInt(6, 8)): + with self.assertNumQueries(FuzzyInt(9, 11)): # Django session, user, team, org membership, instance setting, org, # count, action self.client.get(f"/api/projects/{self.team.id}/actions/") @@ -361,7 +361,7 @@ def test_listing_actions_is_not_nplus1(self) -> None: # Pre-query to cache things like instance settings self.client.get(f"/api/projects/{self.team.id}/actions/") - with self.assertNumQueries(6), snapshot_postgres_queries_context(self): + with self.assertNumQueries(9), snapshot_postgres_queries_context(self): self.client.get(f"/api/projects/{self.team.id}/actions/") Action.objects.create( @@ -370,7 +370,7 @@ def test_listing_actions_is_not_nplus1(self) -> None: created_by=User.objects.create_and_join(self.organization, "a", ""), ) - with self.assertNumQueries(6), snapshot_postgres_queries_context(self): + with self.assertNumQueries(9), snapshot_postgres_queries_context(self): self.client.get(f"/api/projects/{self.team.id}/actions/") Action.objects.create( @@ -379,7 +379,7 @@ def test_listing_actions_is_not_nplus1(self) -> None: created_by=User.objects.create_and_join(self.organization, "b", ""), ) - with self.assertNumQueries(6), snapshot_postgres_queries_context(self): + with self.assertNumQueries(9), snapshot_postgres_queries_context(self): self.client.get(f"/api/projects/{self.team.id}/actions/") def test_get_tags_on_non_ee_returns_empty_list(self): diff --git a/posthog/api/test/test_activity_log.py b/posthog/api/test/test_activity_log.py index 2edd7219b71a3..87fa8970277e4 100644 --- a/posthog/api/test/test_activity_log.py +++ b/posthog/api/test/test_activity_log.py @@ -298,7 +298,7 @@ def test_notifications_viewed_n_plus_1(self) -> None: user=user, defaults={"last_viewed_activity_date": f"2023-0{i}-17T04:36:50Z"} ) - with self.assertNumQueries(FuzzyInt(39, 39)): + with self.assertNumQueries(FuzzyInt(42, 42)): self.client.get(f"/api/projects/{self.team.id}/activity_log/important_changes") def test_can_list_all_activity(self) -> None: diff --git a/posthog/api/test/test_annotation.py b/posthog/api/test/test_annotation.py index 0a1f2396d42d9..842f2dde432d5 100644 --- a/posthog/api/test/test_annotation.py +++ b/posthog/api/test/test_annotation.py @@ -36,7 +36,7 @@ def test_retrieving_annotation_is_not_n_plus_1(self, _mock_capture) -> None: """ see https://sentry.io/organizations/posthog/issues/3706110236/events/db0167ece56649f59b013cbe9de7ba7a/?project=1899813 """ - with self.assertNumQueries(FuzzyInt(6, 7)), snapshot_postgres_queries_context(self): + with self.assertNumQueries(FuzzyInt(8, 9)), snapshot_postgres_queries_context(self): response = self.client.get(f"/api/projects/{self.team.id}/annotations/").json() self.assertEqual(len(response["results"]), 0) @@ -48,7 +48,7 @@ def test_retrieving_annotation_is_not_n_plus_1(self, _mock_capture) -> None: content=now().isoformat(), ) - with self.assertNumQueries(FuzzyInt(6, 7)), snapshot_postgres_queries_context(self): + with self.assertNumQueries(FuzzyInt(8, 9)), snapshot_postgres_queries_context(self): response = self.client.get(f"/api/projects/{self.team.id}/annotations/").json() self.assertEqual(len(response["results"]), 1) @@ -60,7 +60,7 @@ def test_retrieving_annotation_is_not_n_plus_1(self, _mock_capture) -> None: content=now().isoformat(), ) - with self.assertNumQueries(FuzzyInt(6, 7)), snapshot_postgres_queries_context(self): + with self.assertNumQueries(FuzzyInt(8, 9)), snapshot_postgres_queries_context(self): response = self.client.get(f"/api/projects/{self.team.id}/annotations/").json() self.assertEqual(len(response["results"]), 2) diff --git a/posthog/api/test/test_cohort.py b/posthog/api/test/test_cohort.py index 52dea5f41a9e0..5e16d6b7bc519 100644 --- a/posthog/api/test/test_cohort.py +++ b/posthog/api/test/test_cohort.py @@ -241,7 +241,7 @@ def test_list_cohorts_is_not_nplus1(self, patch_calculate_cohort, patch_capture) ) self.assertEqual(response.status_code, 201, response.content) - with self.assertNumQueries(9): + with self.assertNumQueries(12): response = self.client.get(f"/api/projects/{self.team.id}/cohorts") assert len(response.json()["results"]) == 1 @@ -256,7 +256,7 @@ def test_list_cohorts_is_not_nplus1(self, patch_calculate_cohort, patch_capture) ) self.assertEqual(response.status_code, 201, response.content) - with self.assertNumQueries(9): + with self.assertNumQueries(12): response = self.client.get(f"/api/projects/{self.team.id}/cohorts") assert len(response.json()["results"]) == 3 diff --git a/posthog/api/test/test_decide.py b/posthog/api/test/test_decide.py index ecc40e634a432..63505d8f7048f 100644 --- a/posthog/api/test/test_decide.py +++ b/posthog/api/test/test_decide.py @@ -4699,7 +4699,7 @@ def test_local_evaluation(self, mock_rate_limit, mock_capture): response = self.client.get(f"/api/feature_flag/local_evaluation") self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) - with self.assertNumQueries(3, using="replica"), self.assertNumQueries(5, using="default"): + with self.assertNumQueries(3, using="replica"), self.assertNumQueries(12, using="default"): # Captured queries for write DB: # E 1. UPDATE "posthog_personalapikey" SET "last_used_at" = '2023-08-01T11:26:50.728057+00:00' # E 2. SELECT "posthog_team"."id", "posthog_team"."uuid", "posthog_team"."organization_id" @@ -4940,7 +4940,7 @@ def test_local_evaluation_for_cohorts(self, mock_rate_limit, mock_capture): PersonalAPIKey.objects.create(label="X", user=self.user, secure_value=hash_key_value(personal_api_key)) cache.clear() - with self.assertNumQueries(4, using="replica"), self.assertNumQueries(5, using="default"): + with self.assertNumQueries(4, using="replica"), self.assertNumQueries(12, using="default"): # Captured queries for write DB: # E 1. UPDATE "posthog_personalapikey" SET "last_used_at" = '2023-08-01T11:26:50.728057+00:00' # E 2. SELECT "posthog_team"."id", "posthog_team"."uuid", "posthog_team"."organization_id" @@ -5210,7 +5210,7 @@ def test_local_evaluation_for_arbitrary_cohorts(self, mock_rate_limit, mock_capt client.logout() self.client.logout() - with self.assertNumQueries(4, using="replica"), self.assertNumQueries(5, using="default"): + with self.assertNumQueries(4, using="replica"), self.assertNumQueries(12, using="default"): # Captured queries for write DB: # E 1. UPDATE "posthog_personalapikey" SET "last_used_at" = '2023-08-01T11:26:50.728057+00:00' # E 2. SELECT "posthog_team"."id", "posthog_team"."uuid", "posthog_team"."organization_id" diff --git a/posthog/api/test/test_event.py b/posthog/api/test/test_event.py index 595d55e9ba48c..65019511b5758 100644 --- a/posthog/api/test/test_event.py +++ b/posthog/api/test/test_event.py @@ -97,7 +97,7 @@ def test_filter_events_by_event_name(self): # Django session, PostHog user, PostHog team, PostHog org membership, # instance setting check, person and distinct id - with self.assertNumQueries(7): + with self.assertNumQueries(9): response = self.client.get(f"/api/projects/{self.team.id}/events/?event=event_name").json() self.assertEqual(response["results"][0]["event"], "event_name") @@ -125,7 +125,7 @@ def test_filter_events_by_properties(self): # Django session, PostHog user, PostHog team, PostHog org membership, # look up if rate limit is enabled (cached after first lookup), instance # setting (poe, rate limit), person and distinct id - expected_queries = 8 + expected_queries = 10 with self.assertNumQueries(expected_queries): response = self.client.get( diff --git a/posthog/api/test/test_feature_flag.py b/posthog/api/test/test_feature_flag.py index 2d4745313b90e..86cee8950dfdf 100644 --- a/posthog/api/test/test_feature_flag.py +++ b/posthog/api/test/test_feature_flag.py @@ -1244,7 +1244,7 @@ def test_my_flags_is_not_nplus1(self) -> None: format="json", ).json() - with self.assertNumQueries(FuzzyInt(5, 6)): + with self.assertNumQueries(FuzzyInt(8, 9)): response = self.client.get(f"/api/projects/{self.team.id}/feature_flags/my_flags") self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1259,7 +1259,7 @@ def test_my_flags_is_not_nplus1(self) -> None: format="json", ).json() - with self.assertNumQueries(FuzzyInt(5, 6)): + with self.assertNumQueries(FuzzyInt(7, 8)): response = self.client.get(f"/api/projects/{self.team.id}/feature_flags/my_flags") self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1274,7 +1274,7 @@ def test_getting_flags_is_not_nplus1(self) -> None: format="json", ).json() - with self.assertNumQueries(FuzzyInt(11, 12)): + with self.assertNumQueries(FuzzyInt(14, 15)): response = self.client.get(f"/api/projects/{self.team.id}/feature_flags") self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1289,7 +1289,7 @@ def test_getting_flags_is_not_nplus1(self) -> None: format="json", ).json() - with self.assertNumQueries(FuzzyInt(11, 12)): + with self.assertNumQueries(FuzzyInt(14, 15)): response = self.client.get(f"/api/projects/{self.team.id}/feature_flags") self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -1313,7 +1313,7 @@ def test_getting_flags_with_no_creator(self) -> None: name="Flag role access", ) - with self.assertNumQueries(FuzzyInt(11, 12)): + with self.assertNumQueries(FuzzyInt(14, 15)): response = self.client.get(f"/api/projects/{self.team.id}/feature_flags") self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(len(response.json()["results"]), 2) @@ -2229,19 +2229,23 @@ def test_local_evaluation_for_invalid_cohorts(self, mock_capture): self.client.logout() - with self.assertNumQueries(12): - # E 1. SAVEPOINT - # E 2. SELECT "posthog_personalapikey"."id" - # E 3. RELEASE SAVEPOINT - # E 4. UPDATE "posthog_personalapikey" SET "last_used_at" = '2024-01-31T13:01:37.394080+00:00' - # E 5. SELECT "posthog_team"."id", "posthog_team"."uuid" - # E 6. SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id" - # E 7. SELECT "posthog_cohort"."id" -- all cohorts - # E 8. SELECT "posthog_featureflag"."id", "posthog_featureflag"."key", -- all flags - # E 9. SELECT "posthog_cohort". id = 99999 - # E 10. SELECT "posthog_cohort". id = deleted cohort - # E 11. SELECT "posthog_cohort". id = cohort from other team - # E 12. SELECT "posthog_grouptypemapping"."id", -- group type mapping + with self.assertNumQueries(16): + # 1. SAVEPOINT + # 2. SELECT "posthog_personalapikey"."id", + # 3. RELEASE SAVEPOINT + # 4. UPDATE "posthog_personalapikey" SET "last_used_at" + # 5. SELECT "posthog_team"."id", "posthog_team"."uuid", + # 6. SELECT "posthog_team"."id", "posthog_team"."uuid", + # 7. SELECT "posthog_project"."id", "posthog_project"."organization_id", + # 8. SELECT "posthog_organizationmembership"."id", + # 9. SELECT "ee_accesscontrol"."id", + # 10. SELECT "posthog_organizationmembership"."id", + # 11. SELECT "posthog_cohort"."id" -- all cohorts + # 12. SELECT "posthog_featureflag"."id", "posthog_featureflag"."key", -- all flags + # 13. SELECT "posthog_cohort". id = 99999 + # 14. SELECT "posthog_cohort". id = deleted cohort + # 15. SELECT "posthog_cohort". id = cohort from other team + # 16. SELECT "posthog_grouptypemapping"."id", -- group type mapping response = self.client.get( f"/api/feature_flag/local_evaluation?token={self.team.api_token}&send_cohorts", diff --git a/posthog/api/test/test_insight.py b/posthog/api/test/test_insight.py index e724252dcd105..eca2b96230c8b 100644 --- a/posthog/api/test/test_insight.py +++ b/posthog/api/test/test_insight.py @@ -506,11 +506,11 @@ def test_listing_insights_does_not_nplus1(self) -> None: # adding more insights doesn't change the query count self.assertEqual( [ - FuzzyInt(10, 11), - FuzzyInt(10, 11), - FuzzyInt(10, 11), - FuzzyInt(10, 11), - FuzzyInt(10, 11), + FuzzyInt(12, 13), + FuzzyInt(12, 13), + FuzzyInt(12, 13), + FuzzyInt(12, 13), + FuzzyInt(12, 13), ], query_counts, f"received query counts\n\n{query_counts}", diff --git a/posthog/api/test/test_organization.py b/posthog/api/test/test_organization.py index 976ddf99cfcb5..5d15a5c94b565 100644 --- a/posthog/api/test/test_organization.py +++ b/posthog/api/test/test_organization.py @@ -159,6 +159,51 @@ def test_projects_outside_personal_api_key_scoped_organizations_not_listed(self) "Only the scoped organization should be listed, the other one should be excluded", ) + def test_delete_organizations_and_verify_list(self): + self.organization_membership.level = OrganizationMembership.Level.OWNER + self.organization_membership.save() + + # Create two additional organizations + org2 = Organization.objects.bootstrap(self.user)[0] + org3 = Organization.objects.bootstrap(self.user)[0] + + self.user.current_organization_id = self.organization.id + self.user.save() + + # Verify we start with 3 organizations + response = self.client.get("/api/organizations/") + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(len(response.json()["results"]), 3) + + # Delete first organization and verify list + response = self.client.delete(f"/api/organizations/{org2.id}") + self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) + response = self.client.get("/api/organizations/") + self.assertEqual(len(response.json()["results"]), 2) + org_ids = {org["id"] for org in response.json()["results"]} + self.assertEqual(org_ids, {str(self.organization.id), str(org3.id)}) + + # Delete second organization and verify list + response = self.client.delete(f"/api/organizations/{org3.id}") + self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) + response = self.client.get("/api/organizations/") + self.assertEqual(len(response.json()["results"]), 1) + self.assertEqual(response.json()["results"][0]["id"], str(self.organization.id)) + + # Verify we can't delete the last organization + response = self.client.delete(f"/api/organizations/{self.organization.id}") + self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) + response = self.client.get("/api/organizations/") + self.assertEqual( + response.json(), + { + "type": "invalid_request", + "code": "not_found", + "detail": "You need to belong to an organization.", + "attr": None, + }, + ) + def create_organization(name: str) -> Organization: """ diff --git a/posthog/api/test/test_organization_feature_flag.py b/posthog/api/test/test_organization_feature_flag.py index 65c43575f9b7e..c069987b82c77 100644 --- a/posthog/api/test/test_organization_feature_flag.py +++ b/posthog/api/test/test_organization_feature_flag.py @@ -115,10 +115,10 @@ def test_copy_feature_flag_create_new(self): "ensure_experience_continuity": self.feature_flag_to_copy.ensure_experience_continuity, "rollout_percentage": self.rollout_percentage_to_copy, "deleted": False, - "created_by": self.user.id, - "id": "__ignore__", - "created_at": "__ignore__", - "usage_dashboard": "__ignore__", + "created_by": ANY, + "id": ANY, + "created_at": ANY, + "usage_dashboard": ANY, "is_simple_flag": True, "experiment_set": [], "surveys": [], @@ -129,22 +129,13 @@ def test_copy_feature_flag_create_new(self): "analytics_dashboards": [], "has_enriched_analytics": False, "tags": [], + "user_access_level": "editor", } flag_response = response.json()["success"][0] - for key, expected_value in expected_flag_response.items(): - self.assertIn(key, flag_response) - if expected_value != "__ignore__": - if key == "created_by": - self.assertEqual(flag_response[key]["id"], expected_value) - else: - self.assertEqual(flag_response[key], expected_value) - - self.assertSetEqual( - set(expected_flag_response.keys()), - set(flag_response.keys()), - ) + assert flag_response == expected_flag_response + assert flag_response["created_by"]["id"] == self.user.id def test_copy_feature_flag_update_existing(self): target_project = self.team_2 @@ -201,43 +192,34 @@ def test_copy_feature_flag_update_existing(self): "ensure_experience_continuity": self.feature_flag_to_copy.ensure_experience_continuity, "rollout_percentage": self.rollout_percentage_to_copy, "deleted": False, - "created_by": self.user.id, + "created_by": ANY, "is_simple_flag": True, "rollback_conditions": None, "performed_rollback": False, "can_edit": True, "has_enriched_analytics": False, "tags": [], - "id": "__ignore__", - "created_at": "__ignore__", - "usage_dashboard": "__ignore__", - "experiment_set": "__ignore__", - "surveys": "__ignore__", - "features": "__ignore__", - "analytics_dashboards": "__ignore__", + "id": ANY, + "created_at": ANY, + "usage_dashboard": ANY, + "experiment_set": ANY, + "surveys": ANY, + "features": ANY, + "analytics_dashboards": ANY, + "user_access_level": "editor", } flag_response = response.json()["success"][0] - for key, expected_value in expected_flag_response.items(): - self.assertIn(key, flag_response) - if expected_value != "__ignore__": - if key == "created_by": - self.assertEqual(flag_response[key]["id"], expected_value) - else: - self.assertEqual(flag_response[key], expected_value) + assert flag_response == expected_flag_response # Linked instances must remain linked - self.assertEqual(experiment.id, flag_response["experiment_set"][0]) - self.assertEqual(str(survey.id), flag_response["surveys"][0]["id"]) - self.assertEqual(str(feature.id), flag_response["features"][0]["id"]) - self.assertEqual(analytics_dashboard.id, flag_response["analytics_dashboards"][0]) - self.assertEqual(usage_dashboard.id, flag_response["usage_dashboard"]) - - self.assertSetEqual( - set(expected_flag_response.keys()), - set(flag_response.keys()), - ) + assert flag_response["created_by"]["id"] == self.user.id + assert experiment.id == flag_response["experiment_set"][0] + assert str(survey.id) == flag_response["surveys"][0]["id"] + assert str(feature.id) == flag_response["features"][0]["id"] + assert analytics_dashboard.id == flag_response["analytics_dashboards"][0] + assert usage_dashboard.id == flag_response["usage_dashboard"] def test_copy_feature_flag_with_old_legacy_flags(self): url = f"/api/organizations/{self.organization.id}/feature_flags/copy_flags" @@ -331,42 +313,33 @@ def test_copy_feature_flag_update_override_deleted(self): "ensure_experience_continuity": self.feature_flag_to_copy.ensure_experience_continuity, "rollout_percentage": self.rollout_percentage_to_copy, "deleted": False, - "created_by": self.user.id, + "created_by": ANY, "is_simple_flag": True, "rollback_conditions": None, "performed_rollback": False, "can_edit": True, "has_enriched_analytics": False, "tags": [], - "id": "__ignore__", - "created_at": "__ignore__", - "usage_dashboard": "__ignore__", - "experiment_set": "__ignore__", - "surveys": "__ignore__", - "features": "__ignore__", - "analytics_dashboards": "__ignore__", + "id": ANY, + "created_at": ANY, + "usage_dashboard": ANY, + "experiment_set": ANY, + "surveys": ANY, + "features": ANY, + "analytics_dashboards": ANY, + "user_access_level": "editor", } flag_response = response.json()["success"][0] - for key, expected_value in expected_flag_response.items(): - self.assertIn(key, flag_response) - if expected_value != "__ignore__": - if key == "created_by": - self.assertEqual(flag_response[key]["id"], expected_value) - else: - self.assertEqual(flag_response[key], expected_value) + assert flag_response == expected_flag_response + assert flag_response["created_by"]["id"] == self.user.id - # Linked instances must be overriden for a soft-deleted flag + # Linked instances must be overridden for a soft-deleted flag self.assertEqual(flag_response["experiment_set"], []) self.assertEqual(flag_response["surveys"], []) self.assertNotEqual(flag_response["usage_dashboard"], existing_deleted_flag.usage_dashboard.id) self.assertEqual(flag_response["analytics_dashboards"], []) - self.assertSetEqual( - set(expected_flag_response.keys()), - set(flag_response.keys()), - ) - # target_project_2 should have failed self.assertEqual(len(response.json()["failed"]), 1) self.assertEqual(response.json()["failed"][0]["project_id"], target_project_2.id) diff --git a/posthog/api/test/test_person.py b/posthog/api/test/test_person.py index b58ed858d9e8a..2c9694f6eda6d 100644 --- a/posthog/api/test/test_person.py +++ b/posthog/api/test/test_person.py @@ -873,7 +873,7 @@ def test_pagination_limit(self): create_person(team_id=self.team.pk, version=0) returned_ids = [] - with self.assertNumQueries(8): + with self.assertNumQueries(10): response = self.client.get("/api/person/?limit=10").json() self.assertEqual(len(response["results"]), 9) returned_ids += [x["distinct_ids"][0] for x in response["results"]] @@ -884,7 +884,7 @@ def test_pagination_limit(self): created_ids.reverse() # ids are returned in desc order self.assertEqual(returned_ids, created_ids, returned_ids) - with self.assertNumQueries(6): + with self.assertNumQueries(8): response_include_total = self.client.get("/api/person/?limit=10&include_total").json() self.assertEqual(response_include_total["count"], 20) # With `include_total`, the total count is returned too diff --git a/posthog/api/test/test_plugin.py b/posthog/api/test/test_plugin.py index 10967d63bb873..0757ac6813c0a 100644 --- a/posthog/api/test/test_plugin.py +++ b/posthog/api/test/test_plugin.py @@ -956,22 +956,22 @@ def test_can_access_global_plugin_even_if_not_in_org(self, mock_get, mock_reload @snapshot_postgres_queries def test_listing_plugins_is_not_nplus1(self, _mock_get, _mock_reload) -> None: - with self.assertNumQueries(8): + with self.assertNumQueries(10): self._assert_number_of_when_listed_plugins(0) Plugin.objects.create(organization=self.organization) - with self.assertNumQueries(8): + with self.assertNumQueries(10): self._assert_number_of_when_listed_plugins(1) Plugin.objects.create(organization=self.organization) - with self.assertNumQueries(8): + with self.assertNumQueries(10): self._assert_number_of_when_listed_plugins(2) Plugin.objects.create(organization=self.organization) - with self.assertNumQueries(8): + with self.assertNumQueries(10): self._assert_number_of_when_listed_plugins(3) def _assert_number_of_when_listed_plugins(self, expected_plugins_count: int) -> None: diff --git a/posthog/api/test/test_survey.py b/posthog/api/test/test_survey.py index ee1cc97a6962b..0c79b33518c7b 100644 --- a/posthog/api/test/test_survey.py +++ b/posthog/api/test/test_survey.py @@ -391,7 +391,7 @@ def test_used_in_survey_is_populated_correctly_for_feature_flag_list(self) -> No format="json", ).json() - with self.assertNumQueries(16): + with self.assertNumQueries(20): response = self.client.get(f"/api/projects/{self.team.id}/feature_flags") self.assertEqual(response.status_code, status.HTTP_200_OK) result = response.json() diff --git a/posthog/middleware.py b/posthog/middleware.py index 71b5e2563e084..ee132dc78d0af 100644 --- a/posthog/middleware.py +++ b/posthog/middleware.py @@ -5,7 +5,7 @@ from typing import Any, Optional, cast from collections.abc import Callable from loginas.utils import is_impersonated_session, restore_original_login - +from posthog.rbac.user_access_control import UserAccessControl from django.shortcuts import redirect import structlog from corsheaders.middleware import CorsMiddleware @@ -274,6 +274,14 @@ def switch_team_if_allowed(self, new_team: Team, request: HttpRequest): def can_switch_to_team(self, new_team: Team, request: HttpRequest): user = cast(User, request.user) user_permissions = UserPermissions(user) + user_access_control = UserAccessControl(user=user, team=new_team) + + # :KLUDGE: This is more inefficient than needed, doing several expensive lookups + # However this should be a rare operation! + if not user_access_control.check_access_level_for_object(new_team, "member"): + # Do something to indicate that they don't have access to the team... + return False + # :KLUDGE: This is more inefficient than needed, doing several expensive lookups # However this should be a rare operation! if user_permissions.team(new_team).effective_membership_level is None: diff --git a/posthog/permissions.py b/posthog/permissions.py index 6de160e099567..4f49616cd5875 100644 --- a/posthog/permissions.py +++ b/posthog/permissions.py @@ -1,15 +1,15 @@ +from typing import Optional, cast import time -from typing import cast from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db.models import Model -from django.views import View import posthoganalytics from rest_framework.exceptions import NotFound, PermissionDenied from rest_framework.permissions import SAFE_METHODS, BasePermission, IsAdminUser from rest_framework.request import Request from rest_framework.views import APIView +from rest_framework.viewsets import ViewSet from posthog.auth import ( PersonalAPIKeyAuthentication, @@ -19,13 +19,14 @@ from posthog.cloud_utils import is_cloud from posthog.exceptions import EnterpriseFeatureException from posthog.models import Organization, OrganizationMembership, Team, User -from posthog.models.scopes import APIScopeObjectOrNotSupported +from posthog.models.scopes import APIScopeObject, APIScopeObjectOrNotSupported +from posthog.rbac.user_access_control import AccessControlLevel, UserAccessControl, ordered_access_levels from posthog.utils import get_can_create_org -CREATE_METHODS = ["POST", "PUT"] +CREATE_ACTIONS = ["create", "update"] -def extract_organization(object: Model, view: View) -> Organization: +def extract_organization(object: Model, view: ViewSet) -> Organization: # This is set as part of the TeamAndOrgViewSetMixin to allow models that are not directly related to an organization organization_id_rewrite = getattr(view, "filter_rewrite_rules", {}).get("organization_id") if organization_id_rewrite: @@ -101,10 +102,13 @@ def has_permission(self, request: Request, view) -> bool: organization = get_organization_from_view(view) + # TODO: Optimize this - we can get it from view.user_access_control return OrganizationMembership.objects.filter(user=cast(User, request.user), organization=organization).exists() - def has_object_permission(self, request: Request, view: View, object: Model) -> bool: + def has_object_permission(self, request: Request, view, object: Model) -> bool: organization = extract_organization(object, view) + + # TODO: Optimize this - we can get it from view.user_access_control return OrganizationMembership.objects.filter(user=cast(User, request.user), organization=organization).exists() @@ -135,7 +139,7 @@ def has_permission(self, request: Request, view) -> bool: return membership.level >= OrganizationMembership.Level.ADMIN - def has_object_permission(self, request: Request, view: View, object: Model) -> bool: + def has_object_permission(self, request: Request, view, object: Model) -> bool: if request.method in SAFE_METHODS: return True @@ -295,15 +299,9 @@ def has_permission(self, request, view) -> bool: return True -class APIScopePermission(BasePermission): +class ScopeBasePermission(BasePermission): """ - The request is via an API key and the user has the appropriate scopes. - - This permission requires that the view has a "scope" attribute which is the base scope required for the action. - E.g. scope="insight" for a view that requires "insight:read" or "insight:write" for the relevant actions. - - Actions can override this default scope by setting the `required_scopes` attribute on the view method. - + Base class for shared functionality between APIScopePermission and AccessControlPermission """ write_actions: list[str] = ["create", "update", "partial_update", "patch", "destroy"] @@ -311,18 +309,57 @@ class APIScopePermission(BasePermission): scope_object_read_actions: list[str] = [] scope_object_write_actions: list[str] = [] + def _get_scope_object(self, request, view) -> APIScopeObjectOrNotSupported: + if not getattr(view, "scope_object", None): + raise ImproperlyConfigured("APIScopePermission requires the view to define the scope_object attribute.") + + return view.scope_object + def _get_action(self, request, view) -> str: # TRICKY: DRF doesn't have an action for non-detail level "patch" calls which we use sometimes - if not view.action: if request.method == "PATCH" and not view.detail: return "patch" return view.action + def _get_required_scopes(self, request, view) -> Optional[list[str]]: + # If required_scopes is set on the view method then use that + # Otherwise use the scope_object and derive the required scope from the action + if getattr(view, "required_scopes", None): + return view.required_scopes + + scope_object = self._get_scope_object(request, view) + + if scope_object == "INTERNAL": + return None + + action = self._get_action(request, view) + read_actions = getattr(view, "scope_object_read_actions", self.read_actions) + write_actions = getattr(view, "scope_object_write_actions", self.write_actions) + + if action in write_actions: + return [f"{scope_object}:write"] + elif action in read_actions or request.method == "OPTIONS": + return [f"{scope_object}:read"] + + return None + + +class APIScopePermission(ScopeBasePermission): + """ + The request is via an API key and the user has the appropriate scopes. + + This permission requires that the view has a "scope" attribute which is the base scope required for the action. + E.g. scope="insight" for a view that requires "insight:read" or "insight:write" for the relevant actions. + + Actions can override this default scope by setting the `required_scopes` attribute on the view method. + + """ + def has_permission(self, request, view) -> bool: # NOTE: We do this first to error out quickly if the view is missing the required attribute # Helps devs remember to add it. - self.get_scope_object(request, view) + self._get_scope_object(request, view) # API Scopes currently only apply to PersonalAPIKeyAuthentication if not isinstance(request.successful_authenticator, PersonalAPIKeyAuthentication): @@ -334,7 +371,12 @@ def has_permission(self, request, view) -> bool: if not key_scopes: return True - required_scopes = self.get_required_scopes(request, view) + required_scopes = self._get_required_scopes(request, view) + + if not required_scopes: + self.message = f"This action does not support Personal API Key access" + return False + self.check_team_and_org_permissions(request, view) if "*" in key_scopes: @@ -354,7 +396,7 @@ def has_permission(self, request, view) -> bool: return True def check_team_and_org_permissions(self, request, view) -> None: - scope_object = self.get_scope_object(request, view) + scope_object = self._get_scope_object(request, view) if scope_object == "user": return # The /api/users/@me/ endpoint is exempt from team and org scoping @@ -380,35 +422,104 @@ def check_team_and_org_permissions(self, request, view) -> None: # Indicates this is not an organization scoped view pass - def get_required_scopes(self, request, view) -> list[str]: - # If required_scopes is set on the view method then use that - # Otherwise use the scope_object and derive the required scope from the action - if getattr(view, "required_scopes", None): - return view.required_scopes - scope_object = self.get_scope_object(request, view) +class AccessControlPermission(ScopeBasePermission): + """ + Unified permissions access - controls access to any object based on the user's access controls + """ - if scope_object == "INTERNAL": - raise PermissionDenied(f"This action does not support Personal API Key access") + def _get_user_access_control(self, request, view) -> UserAccessControl: + return view.user_access_control - action = self._get_action(request, view) - read_actions = getattr(view, "scope_object_read_actions", self.read_actions) - write_actions = getattr(view, "scope_object_write_actions", self.write_actions) + def _get_required_access_level(self, request, view) -> Optional[AccessControlLevel]: + resource = self._get_scope_object(request, view) + required_scopes = self._get_required_scopes(request, view) - if action in write_actions: - return [f"{scope_object}:write"] - elif action in read_actions or request.method == "OPTIONS": - return [f"{scope_object}:read"] + if resource == "INTERNAL": + return None - # If we get here this typically means an action was called without a required scope - # It is essentially "INTERNAL" - raise PermissionDenied(f"This action does not support Personal API Key access") + READ_LEVEL = ordered_access_levels(resource)[-2] + WRITE_LEVEL = ordered_access_levels(resource)[-1] - def get_scope_object(self, request, view) -> APIScopeObjectOrNotSupported: - if not getattr(view, "scope_object", None): - raise ImproperlyConfigured("APIScopePermission requires the view to define the scope_object attribute.") + if not required_scopes: + return READ_LEVEL if request.method in SAFE_METHODS else WRITE_LEVEL - return view.scope_object + # TODO: This is definitely not right - we need to more safely map the scopes to access levels relevant to the object + for scope in required_scopes: + if scope.endswith(":write"): + return WRITE_LEVEL + + return READ_LEVEL + + def has_object_permission(self, request, view, object) -> bool: + # At this level we are checking an individual resource - this could be a project or a lower level item like a Dashboard + + # NOTE: If the object is a Team then we shortcircuit here and create a UAC + # Reason being that there is a loop from view.user_access_control -> view.team -> view.user_access_control + if isinstance(object, Team): + uac = UserAccessControl(user=request.user, team=object) + else: + uac = self._get_user_access_control(request, view) + + if not uac: + # If the view doesn't have a user_access_control then it is not supported by this permission scheme + return True + + required_level = self._get_required_access_level(request, view) + + if not required_level: + return True + + has_access = uac.check_access_level_for_object(object, required_level=required_level) + + if not has_access: + self.message = f"You do not have {required_level} access to this resource." + return False + + return True + + def has_permission(self, request, view) -> bool: + # At this level we are checking that the user can generically access the resource kind. + # Primarily we are checking the user's access to the parent resource type (i.e. project, organization) + # as well as enforcing any global restrictions (e.g. generically only editing of a flag is allowed) + + uac = self._get_user_access_control(request, view) + scope_object = self._get_scope_object(request, view) + required_level = self._get_required_access_level(request, view) + + team: Team + + try: + team = view.team + except (ValueError, KeyError): + # TODO: Change this to a super specific exception... + # TODO: Does this means its okay because there is no team level thing? + return True + + # NOTE: This isn't perfect as it will only optimize for endpoints where the pk matches the obj.id + # We can't load the actual object as get_object in turn calls the permissions check + pk = view.kwargs.get("pk") + uac.preload_access_levels(team=team, resource=cast(APIScopeObject, scope_object), resource_id=pk) + + is_member = uac.check_access_level_for_object(team, required_level="member") + + if not is_member: + self.message = f"You don't have access to the project." + return False + + # If the API doesn't have a scope object or a required level for accessing then we can simply allow access + # as it isn't under access control + if scope_object == "INTERNAL" or not required_level: + return True + + # TODO: Scope object should probably be applied against the `required_scopes` attribute + has_access = uac.check_access_level_for_resource(scope_object, required_level=required_level) + + if not has_access: + self.message = f"You do not have {required_level} access to this resource." + return False + + return True class PostHogFeatureFlagPermission(BasePermission): diff --git a/posthog/rbac/access_control_api_mixin.py b/posthog/rbac/access_control_api_mixin.py new file mode 100644 index 0000000000000..ec684d56b7238 --- /dev/null +++ b/posthog/rbac/access_control_api_mixin.py @@ -0,0 +1,13 @@ +from typing import TYPE_CHECKING + + +if TYPE_CHECKING: + from ee.api.rbac.access_control import AccessControlViewSetMixin +else: + try: + from ee.api.rbac.access_control import AccessControlViewSetMixin + + except ImportError: + + class AccessControlViewSetMixin: + pass diff --git a/posthog/rbac/test/test_user_access_control.py b/posthog/rbac/test/test_user_access_control.py new file mode 100644 index 0000000000000..69eb51431c587 --- /dev/null +++ b/posthog/rbac/test/test_user_access_control.py @@ -0,0 +1,559 @@ +import pytest +from posthog.constants import AvailableFeature +from posthog.models.dashboard import Dashboard +from posthog.models.organization import OrganizationMembership +from posthog.models.team.team import Team +from posthog.models.user import User +from posthog.rbac.user_access_control import UserAccessControl +from posthog.test.base import BaseTest + + +try: + from ee.models.rbac.access_control import AccessControl + from ee.models.rbac.role import Role, RoleMembership +except ImportError: + pass + + +class BaseUserAccessControlTest(BaseTest): + user_access_control: UserAccessControl + + def _create_access_control( + self, resource="project", resource_id=None, access_level="admin", organization_member=None, team=None, role=None + ): + ac, _ = AccessControl.objects.get_or_create( + team=self.team, + resource=resource, + resource_id=resource_id or self.team.id, + organization_member=organization_member, + role=role, + ) + + ac.access_level = access_level + ac.save() + + return ac + + def setUp(self): + super().setUp() + self.organization.available_product_features = [ + { + "key": AvailableFeature.PROJECT_BASED_PERMISSIONING, + "name": AvailableFeature.PROJECT_BASED_PERMISSIONING, + }, + { + "key": AvailableFeature.ROLE_BASED_ACCESS, + "name": AvailableFeature.ROLE_BASED_ACCESS, + }, + ] + self.organization.save() + + self.role_a = Role.objects.create(name="Engineers", organization=self.organization) + self.role_b = Role.objects.create(name="Administrators", organization=self.organization) + + RoleMembership.objects.create(user=self.user, role=self.role_a) + self.user_access_control = UserAccessControl(self.user, self.team) + + self.other_user = User.objects.create_and_join(self.organization, "other@posthog.com", "testtest") + RoleMembership.objects.create(user=self.other_user, role=self.role_b) + self.other_user_access_control = UserAccessControl(self.other_user, self.team) + + self.user_with_no_role = User.objects.create_and_join(self.organization, "norole@posthog.com", "testtest") + self.user_with_no_role_access_control = UserAccessControl(self.user_with_no_role, self.team) + + def _clear_uac_caches(self): + self.user_access_control._clear_cache() + self.other_user_access_control._clear_cache() + self.user_with_no_role_access_control._clear_cache() + + +@pytest.mark.ee +class TestUserAccessControl(BaseUserAccessControlTest): + def test_no_organization_id_passed(self): + # Create a user without an organization + user_without_org = User.objects.create(email="no-org@posthog.com", password="testtest") + user_access_control = UserAccessControl(user_without_org) + + assert user_access_control._organization_membership is None + assert user_access_control._organization is None + assert user_access_control._user_role_ids == [] + + def test_without_available_product_features(self): + self.organization.available_product_features = [] + self.organization.save() + self.organization_membership.level = OrganizationMembership.Level.ADMIN + self.organization_membership.save() + + assert self.user_access_control.access_level_for_object(self.team) == "admin" + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is True + assert self.other_user_access_control.access_level_for_object(self.team) == "admin" + assert self.other_user_access_control.check_access_level_for_object(self.team, "admin") is True + assert self.user_access_control.access_level_for_resource("project") == "admin" + assert self.other_user_access_control.access_level_for_resource("project") == "admin" + assert self.user_access_control.check_can_modify_access_levels_for_object(self.team) is True + assert self.other_user_access_control.check_can_modify_access_levels_for_object(self.team) is False + + def test_ac_object_default_response(self): + self.organization_membership.level = OrganizationMembership.Level.ADMIN + self.organization_membership.save() + + assert self.user_access_control.access_level_for_object(self.team) == "admin" + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is True + assert self.other_user_access_control.access_level_for_object(self.team) == "admin" + assert self.other_user_access_control.check_access_level_for_object(self.team, "admin") is True + assert self.user_access_control.access_level_for_resource("project") == "admin" + assert self.other_user_access_control.access_level_for_resource("project") == "admin" + assert self.user_access_control.check_can_modify_access_levels_for_object(self.team) is True + assert self.other_user_access_control.check_can_modify_access_levels_for_object(self.team) is False + + def test_ac_object_user_access_control(self): + # Setup member access by default + self._create_access_control(resource_id=self.team.id, access_level="member") + ac = self._create_access_control( + resource="project", + resource_id=str(self.team.id), + access_level="admin", + # context + organization_member=self.organization_membership, + ) + + assert self.user_access_control.access_level_for_object(self.team) == "admin" + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is True + assert self.other_user_access_control.check_access_level_for_object(self.team, "admin") is False + + ac.access_level = "member" + ac.save() + self._clear_uac_caches() + + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is False + assert self.user_access_control.check_access_level_for_object(self.team, "member") is True + assert ( + self.other_user_access_control.check_access_level_for_object(self.team, "member") + is True # This is the default + ) # Fix this - need to load all access controls... + + def test_ac_object_project_access_control(self): + # Setup no access by default + ac = self._create_access_control(resource_id=self.team.id, access_level="none") + + assert self.user_access_control.access_level_for_object(self.team) == "none" + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is False + assert self.other_user_access_control.check_access_level_for_object(self.team, "admin") is False + + ac.access_level = "member" + ac.save() + self._clear_uac_caches() + + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is False + assert self.user_access_control.check_access_level_for_object(self.team, "member") is True + assert self.other_user_access_control.check_access_level_for_object(self.team, "admin") is False + assert self.other_user_access_control.check_access_level_for_object(self.team, "member") is True + + ac.access_level = "admin" + ac.save() + self._clear_uac_caches() + + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is True + assert self.other_user_access_control.check_access_level_for_object(self.team, "admin") is True + + def test_ac_object_role_access_control(self): + # Setup member access by default + self._create_access_control(resource_id=self.team.id, access_level="member") + ac = self._create_access_control(resource_id=self.team.id, access_level="admin", role=self.role_a) + + assert self.user_access_control.access_level_for_object(self.team) == "admin" + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is True + assert self.other_user_access_control.check_access_level_for_object(self.team, "admin") is False + assert self.user_with_no_role_access_control.check_access_level_for_object(self.team, "admin") is False + + ac.access_level = "member" + ac.save() + self._clear_uac_caches() + + # Make the default access level none + self._create_access_control(resource_id=self.team.id, access_level="none") + + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is False + assert self.user_access_control.check_access_level_for_object(self.team, "member") is True + assert self.other_user_access_control.check_access_level_for_object(self.team, "admin") is False + assert self.other_user_access_control.check_access_level_for_object(self.team, "member") is False + assert self.user_with_no_role_access_control.check_access_level_for_object(self.team, "admin") is False + + def test_ac_object_mixed_access_controls(self): + # No access by default + ac_project = self._create_access_control(resource_id=self.team.id, access_level="none") + # Enroll self.user as member + ac_user = self._create_access_control( + resource_id=self.team.id, access_level="member", organization_member=self.organization_membership + ) + # Enroll role_a as admin + ac_role = self._create_access_control( + resource_id=self.team.id, access_level="admin", role=self.role_a + ) # The highest AC + # Enroll role_b as member + ac_role_2 = self._create_access_control(resource_id=self.team.id, access_level="member", role=self.role_b) + # Enroll self.user in both roles + RoleMembership.objects.create(user=self.user, role=self.role_b) + + # Create an unrelated access control for self.user + self._create_access_control( + resource_id="something else", access_level="admin", organization_member=self.organization_membership + ) + + matching_acs = self.user_access_control._get_access_controls( + self.user_access_control._access_controls_filters_for_object("project", str(self.team.id)) + ) + assert len(matching_acs) == 4 + assert ac_project in matching_acs + assert ac_user in matching_acs + assert ac_role in matching_acs + assert ac_role_2 in matching_acs + # the matching one should be the highest level + assert self.user_access_control.access_level_for_object(self.team) == "admin" + + def test_org_admin_always_has_access(self): + self._create_access_control(resource_id=self.team.id, access_level="none") + assert self.other_user_access_control.check_access_level_for_object(self.team, "member") is False + assert self.other_user_access_control.check_access_level_for_object(self.team, "admin") is False + + self.organization_membership.level = OrganizationMembership.Level.ADMIN + self.organization_membership.save() + + assert self.user_access_control.check_access_level_for_object(self.team, "member") is True + assert self.user_access_control.check_access_level_for_object(self.team, "admin") is True + + def test_leaving_the_org_revokes_access(self): + self.user.leave(organization=self.organization) + assert self.user_access_control.check_access_level_for_object(self.team, "member") is False + + def test_filters_project_queryset_based_on_acs(self): + team2 = Team.objects.create(organization=self.organization) + team3 = Team.objects.create(organization=self.organization) + # No default access + self._create_access_control(resource="project", resource_id=team2.id, access_level="none") + # No default access + self._create_access_control(resource="project", resource_id=team3.id, access_level="none") + # This user access + self._create_access_control( + resource="project", + resource_id=team3.id, + access_level="member", + organization_member=self.organization_membership, + ) + + # NOTE: This is different to the API queries as the TeamAndOrgViewsetMixing takes care of filtering out based on the parent org + filtered_teams = list(self.user_access_control.filter_queryset_by_access_level(Team.objects.all())) + assert filtered_teams == [self.team, team3] + + other_user_filtered_teams = list( + self.other_user_access_control.filter_queryset_by_access_level(Team.objects.all()) + ) + assert other_user_filtered_teams == [self.team] + + def test_filters_project_queryset_based_on_acs_always_allows_org_admin(self): + team2 = Team.objects.create(organization=self.organization) + team3 = Team.objects.create(organization=self.organization) + # No default access + self._create_access_control(resource="project", resource_id=team2.id, access_level="none") + self._create_access_control(resource="project", resource_id=team3.id, access_level="none") + + self.organization_membership.level = OrganizationMembership.Level.ADMIN + self.organization_membership.save() + + filtered_teams = list( + self.user_access_control.filter_queryset_by_access_level(Team.objects.all(), include_all_if_admin=True) + ) + assert filtered_teams == [self.team, team2, team3] + + def test_organization_access_control(self): + # A team isn't always available like for organization level routing + + self.organization_membership.level = OrganizationMembership.Level.MEMBER + self.organization_membership.save() + + uac = UserAccessControl(user=self.user, organization_id=self.organization.id) + + assert uac.check_access_level_for_object(self.organization, "member") is True + assert uac.check_access_level_for_object(self.organization, "admin") is False + + self.organization_membership.level = OrganizationMembership.Level.ADMIN + self.organization_membership.save() + + uac = UserAccessControl(user=self.user, organization_id=self.organization.id) + + assert uac.check_access_level_for_object(self.organization, "admin") is True + + +class TestUserAccessControlResourceSpecific(BaseUserAccessControlTest): + """ + Most things are identical between "project"s and other resources, but there are some differences particularly in level names + """ + + def setUp(self): + super().setUp() + + self.dashboard = Dashboard.objects.create(team=self.team) + + def test_without_available_product_features(self): + self.organization.available_product_features = [] + self.organization.save() + self.organization_membership.level = OrganizationMembership.Level.ADMIN + self.organization_membership.save() + + assert self.user_access_control.access_level_for_object(self.dashboard) == "editor" + assert self.other_user_access_control.access_level_for_object(self.dashboard) == "editor" + assert self.user_access_control.access_level_for_resource("dashboard") == "editor" + assert self.other_user_access_control.access_level_for_resource("dashboard") == "editor" + + def test_ac_object_default_response(self): + assert self.user_access_control.access_level_for_object(self.dashboard) == "editor" + assert self.other_user_access_control.access_level_for_object(self.dashboard) == "editor" + + +# class TestUserDashboardPermissions(BaseTest, WithPermissionsBase): +# def setUp(self): +# super().setUp() +# self.organization.available_product_features = [ +# {"key": AvailableFeature.ADVANCED_PERMISSIONS, "name": AvailableFeature.ADVANCED_PERMISSIONS}, +# ] +# self.organization.save() +# self.dashboard = Dashboard.objects.create(team=self.team) + +# def dashboard_permissions(self): +# return self.permissions().dashboard(self.dashboard) + +# def test_dashboard_effective_restriction_level(self): +# assert ( +# self.dashboard_permissions().effective_restriction_level +# == Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT +# ) + +# def test_dashboard_effective_restriction_level_explicit(self): +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# self.dashboard.save() + +# assert ( +# self.dashboard_permissions().effective_restriction_level +# == Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# ) + +# def test_dashboard_effective_restriction_level_when_feature_not_available(self): +# self.organization.available_product_features = [] +# self.organization.save() + +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# self.dashboard.save() + +# assert ( +# self.dashboard_permissions().effective_restriction_level +# == Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT +# ) + +# def test_dashboard_can_restrict(self): +# assert not self.dashboard_permissions().can_restrict + +# def test_dashboard_can_restrict_as_admin(self): +# self.organization_membership.level = OrganizationMembership.Level.ADMIN +# self.organization_membership.save() + +# assert self.dashboard_permissions().can_restrict + +# def test_dashboard_can_restrict_as_creator(self): +# self.dashboard.created_by = self.user +# self.dashboard.save() + +# assert self.dashboard_permissions().can_restrict + +# def test_dashboard_effective_privilege_level_when_everyone_can_edit(self): +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT +# self.dashboard.save() + +# assert self.dashboard_permissions().effective_privilege_level == Dashboard.PrivilegeLevel.CAN_EDIT + +# def test_dashboard_effective_privilege_level_when_collaborators_can_edit(self): +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# self.dashboard.save() + +# assert self.dashboard_permissions().effective_privilege_level == Dashboard.PrivilegeLevel.CAN_VIEW + +# def test_dashboard_effective_privilege_level_priviledged(self): +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# self.dashboard.save() + +# DashboardPrivilege.objects.create( +# user=self.user, +# dashboard=self.dashboard, +# level=Dashboard.PrivilegeLevel.CAN_EDIT, +# ) + +# assert self.dashboard_permissions().effective_privilege_level == Dashboard.PrivilegeLevel.CAN_EDIT + +# def test_dashboard_effective_privilege_level_creator(self): +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# self.dashboard.save() +# self.dashboard.created_by = self.user +# self.dashboard.save() + +# assert self.dashboard_permissions().effective_privilege_level == Dashboard.PrivilegeLevel.CAN_EDIT + +# def test_dashboard_can_edit_when_everyone_can(self): +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT +# self.dashboard.save() + +# assert self.dashboard_permissions().can_edit + +# def test_dashboard_can_edit_not_collaborator(self): +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# self.dashboard.save() + +# assert not self.dashboard_permissions().can_edit + +# def test_dashboard_can_edit_creator(self): +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# self.dashboard.save() +# self.dashboard.created_by = self.user +# self.dashboard.save() + +# assert self.dashboard_permissions().can_edit + +# def test_dashboard_can_edit_priviledged(self): +# self.dashboard.restriction_level = Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# self.dashboard.save() + +# DashboardPrivilege.objects.create( +# user=self.user, +# dashboard=self.dashboard, +# level=Dashboard.PrivilegeLevel.CAN_EDIT, +# ) + +# assert self.dashboard_permissions().can_edit + + +# class TestUserInsightPermissions(BaseTest, WithPermissionsBase): +# def setUp(self): +# super().setUp() +# self.organization.available_product_features = [ +# {"key": AvailableFeature.ADVANCED_PERMISSIONS, "name": AvailableFeature.ADVANCED_PERMISSIONS}, +# ] +# self.organization.save() + +# self.dashboard1 = Dashboard.objects.create( +# team=self.team, +# restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT, +# ) +# self.dashboard2 = Dashboard.objects.create(team=self.team) +# self.insight = Insight.objects.create(team=self.team) +# self.tile1 = DashboardTile.objects.create(dashboard=self.dashboard1, insight=self.insight) +# self.tile2 = DashboardTile.objects.create(dashboard=self.dashboard2, insight=self.insight) + +# def insight_permissions(self): +# return self.permissions().insight(self.insight) + +# def test_effective_restriction_level_limited(self): +# assert ( +# self.insight_permissions().effective_restriction_level +# == Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT +# ) + +# def test_effective_restriction_level_all_allow(self): +# Dashboard.objects.all().update(restriction_level=Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT) + +# assert ( +# self.insight_permissions().effective_restriction_level +# == Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT +# ) + +# def test_effective_restriction_level_with_no_dashboards(self): +# DashboardTile.objects.all().delete() + +# assert ( +# self.insight_permissions().effective_restriction_level +# == Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT +# ) + +# def test_effective_restriction_level_with_no_permissioning(self): +# self.organization.available_product_features = [] +# self.organization.save() + +# assert ( +# self.insight_permissions().effective_restriction_level +# == Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT +# ) + +# def test_effective_privilege_level_all_limited(self): +# Dashboard.objects.all().update(restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT) + +# assert self.insight_permissions().effective_privilege_level == Dashboard.PrivilegeLevel.CAN_VIEW + +# def test_effective_privilege_level_some_limited(self): +# assert self.insight_permissions().effective_privilege_level == Dashboard.PrivilegeLevel.CAN_EDIT + +# def test_effective_privilege_level_all_limited_as_collaborator(self): +# Dashboard.objects.all().update(restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT) +# self.dashboard1.created_by = self.user +# self.dashboard1.save() + +# assert self.insight_permissions().effective_privilege_level == Dashboard.PrivilegeLevel.CAN_EDIT + +# def test_effective_privilege_level_with_no_dashboards(self): +# DashboardTile.objects.all().delete() + +# assert self.insight_permissions().effective_privilege_level == Dashboard.PrivilegeLevel.CAN_EDIT + + +# class TestUserPermissionsEfficiency(BaseTest, WithPermissionsBase): +# def test_dashboard_efficiency(self): +# self.organization.available_product_features = [ +# {"key": AvailableFeature.PROJECT_BASED_PERMISSIONING, "name": AvailableFeature.PROJECT_BASED_PERMISSIONING}, +# {"key": AvailableFeature.ADVANCED_PERMISSIONS, "name": AvailableFeature.ADVANCED_PERMISSIONS}, +# ] +# self.organization.save() + +# dashboard = Dashboard.objects.create( +# team=self.team, +# restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT, +# ) +# insights, tiles = [], [] +# for _ in range(10): +# insight = Insight.objects.create(team=self.team) +# tile = DashboardTile.objects.create(dashboard=dashboard, insight=insight) +# insights.append(insight) +# tiles.append(tile) + +# user_permissions = self.permissions() +# user_permissions.set_preloaded_dashboard_tiles(tiles) + +# with self.assertNumQueries(3): +# assert user_permissions.current_team.effective_membership_level is not None +# assert user_permissions.dashboard(dashboard).effective_restriction_level is not None +# assert user_permissions.dashboard(dashboard).can_restrict is not None +# assert user_permissions.dashboard(dashboard).effective_privilege_level is not None +# assert user_permissions.dashboard(dashboard).can_edit is not None + +# for insight in insights: +# assert user_permissions.insight(insight).effective_restriction_level is not None +# assert user_permissions.insight(insight).effective_privilege_level is not None + +# def test_team_lookup_efficiency(self): +# user = User.objects.create(email="test2@posthog.com", distinct_id="test2") +# models = [] +# for _ in range(10): +# organization, membership, team = Organization.objects.bootstrap( +# user=user, team_fields={"access_control": True} +# ) +# membership.level = OrganizationMembership.Level.ADMIN # type: ignore +# membership.save() # type: ignore + +# organization.available_product_features = [ +# {"key": AvailableFeature.PROJECT_BASED_PERMISSIONING, "name": AvailableFeature.PROJECT_BASED_PERMISSIONING}, +# ] +# organization.save() + +# models.append((organization, membership, team)) + +# user_permissions = UserPermissions(user) +# with self.assertNumQueries(3): +# assert len(user_permissions.team_ids_visible_for_user) == 10 + +# for _, _, team in models: +# assert user_permissions.team(team).effective_membership_level == OrganizationMembership.Level.ADMIN diff --git a/posthog/rbac/user_access_control.py b/posthog/rbac/user_access_control.py new file mode 100644 index 0000000000000..12c82e61e8ddd --- /dev/null +++ b/posthog/rbac/user_access_control.py @@ -0,0 +1,489 @@ +from functools import cached_property +import json +from django.contrib.auth.models import AnonymousUser +from django.db.models import Model, Q, QuerySet +from rest_framework import serializers +from typing import TYPE_CHECKING, Any, Literal, Optional, cast, get_args + +from posthog.constants import AvailableFeature +from posthog.models import ( + Organization, + OrganizationMembership, + Team, + User, +) +from posthog.models.scopes import APIScopeObject, API_SCOPE_OBJECTS + + +if TYPE_CHECKING: + from ee.models import AccessControl + + _AccessControl = AccessControl +else: + _AccessControl = object + + +try: + from ee.models.rbac.access_control import AccessControl +except ImportError: + pass + +AccessControlLevelNone = Literal["none"] +AccessControlLevelMember = Literal[AccessControlLevelNone, "member", "admin"] +AccessControlLevelResource = Literal[AccessControlLevelNone, "viewer", "editor"] +AccessControlLevel = Literal[AccessControlLevelMember, AccessControlLevelResource] + +NO_ACCESS_LEVEL = "none" +ACCESS_CONTROL_LEVELS_MEMBER: tuple[AccessControlLevelMember, ...] = get_args(AccessControlLevelMember) +ACCESS_CONTROL_LEVELS_RESOURCE: tuple[AccessControlLevelResource, ...] = get_args(AccessControlLevelResource) + + +def ordered_access_levels(resource: APIScopeObject) -> list[AccessControlLevel]: + if resource in ["project", "organization"]: + return list(ACCESS_CONTROL_LEVELS_MEMBER) + + return list(ACCESS_CONTROL_LEVELS_RESOURCE) + + +def default_access_level(resource: APIScopeObject) -> AccessControlLevel: + if resource in ["project"]: + return "admin" + if resource in ["organization"]: + return "member" + return "editor" + + +def highest_access_level(resource: APIScopeObject) -> AccessControlLevel: + return ordered_access_levels(resource)[-1] + + +def access_level_satisfied_for_resource( + resource: APIScopeObject, current_level: AccessControlLevel, required_level: AccessControlLevel +) -> bool: + return ordered_access_levels(resource).index(current_level) >= ordered_access_levels(resource).index(required_level) + + +def model_to_resource(model: Model) -> Optional[APIScopeObject]: + """ + Given a model, return the resource type it represents + """ + if hasattr(model, "_meta"): + name = model._meta.model_name + else: + name = model.__class__.__name__.lower() + + # NOTE: These are special mappings where the 1-1 of APIScopeObject doesn't match + if name == "team": + return "project" + if name == "featureflag": + return "feature_flag" + if name == "plugin_config": + return "plugin" + + if name not in API_SCOPE_OBJECTS: + return None + + return cast(APIScopeObject, name) + + +class UserAccessControl: + """ + UserAccessControl provides functions for checking unified access to all resources and objects from a Project level downwards. + Typically a Team (Project) is required other than in certain circumstances, particularly when validating which projects a user has access to within an organization. + """ + + def __init__(self, user: User, team: Optional[Team] = None, organization_id: Optional[str] = None): + self._user = user + self._team = team + self._cache: dict[str, list[AccessControl]] = {} + + if not organization_id and team: + organization_id = str(team.organization_id) + + self._organization_id = organization_id + + def _clear_cache(self): + # Primarily intended for tests + self._cache = {} + + @cached_property + def _organization_membership(self) -> Optional[OrganizationMembership]: + # NOTE: This is optimized to reduce queries - we get the users membership _with_ the organization + try: + if not self._organization_id: + return None + return OrganizationMembership.objects.select_related("organization").get( + organization_id=self._organization_id, user=self._user + ) + except OrganizationMembership.DoesNotExist: + return None + + @cached_property + def _organization(self) -> Optional[Organization]: + if self._organization_membership: + return self._organization_membership.organization + return None + + @cached_property + def _user_role_ids(self): + if not self.rbac_supported: + # Early return to prevent an unnecessary lookup + return [] + + role_memberships = cast(Any, self._user).role_memberships.select_related("role").all() + return [membership.role.id for membership in role_memberships] + + @property + def rbac_supported(self) -> bool: + if not self._organization: + return False + + return self._organization.is_feature_available(AvailableFeature.ROLE_BASED_ACCESS) + + @property + def access_controls_supported(self) -> bool: + # NOTE: This is a proxy feature. We may want to consider making it explicit later + # ADVANCED_PERMISSIONS was only for dashboard collaborators, PROJECT_BASED_PERMISSIONING for project permissions + # both now apply to this generic access control + + if not self._organization: + return False + + return self._organization.is_feature_available( + AvailableFeature.PROJECT_BASED_PERMISSIONING + ) or self._organization.is_feature_available(AvailableFeature.ADVANCED_PERMISSIONS) + + def _filter_options(self, filters: dict[str, Any]) -> Q: + """ + Adds the 3 main filter options to the query + """ + return ( + Q( # Access controls applying to this team + **filters, organization_member=None, role=None + ) + | Q( # Access controls applying to this user + **filters, organization_member__user=self._user, role=None + ) + | Q( # Access controls applying to this user's roles + **filters, organization_member=None, role__in=self._user_role_ids + ) + ) + + def _get_access_controls(self, filters: dict) -> list[_AccessControl]: + key = json.dumps(filters, sort_keys=True) + if key not in self._cache: + self._cache[key] = list(AccessControl.objects.filter(self._filter_options(filters))) + + return self._cache[key] + + def _access_controls_filters_for_object(self, resource: APIScopeObject, resource_id: str) -> dict: + """ + Used when checking an individual object - gets all access controls for the object and its type + """ + return {"team_id": self._team.id, "resource": resource, "resource_id": resource_id} # type: ignore + + def _access_controls_filters_for_resource(self, resource: APIScopeObject) -> dict: + """ + Used when checking overall access to a resource + """ + + return {"team_id": self._team.id, "resource": resource, "resource_id": None} # type: ignore + + def _access_controls_filters_for_queryset(self, resource: APIScopeObject) -> dict: + """ + Used to filter out IDs from a queryset based on access controls where the specific resource is denied access + """ + common_filters: dict[str, Any] = {"resource": resource, "resource_id__isnull": False} + + if self._team and resource != "project": + common_filters["team_id"] = self._team.id + else: + common_filters["team__organization_id"] = str(self._organization_id) + + return common_filters + + def _fill_filters_cache(self, filter_groups: list[dict], access_controls: list[_AccessControl]) -> None: + for filters in filter_groups: + key = json.dumps(filters, sort_keys=True) + + # TRICKY: We have to simulate the entire DB query here: + matching_access_controls = [] + + for ac in access_controls: + matches = True + for key, value in filters.items(): + if key == "resource_id__isnull": + if (ac.resource_id is None) != value: + matches = False + break + elif key == "team__organization_id": + if ac.team.organization_id != value: + matches = False + break + elif getattr(ac, key) != value: + matches = False + break + if matches: + matching_access_controls.append(ac) + + self._cache[key] = matching_access_controls + + def preload_object_access_controls(self, objects: list[Model]) -> None: + """ + Preload access controls for a list of objects + """ + + filter_groups: list[dict] = [] + + for obj in objects: + resource = model_to_resource(obj) + if not resource: + return + + filter_groups.append(self._access_controls_filters_for_object(resource, str(obj.id))) # type: ignore + + q = Q() + for filters in filter_groups: + q = q | self._filter_options(filters) + + access_controls = list(AccessControl.objects.filter(q)) + self._fill_filters_cache(filter_groups, access_controls) + + def preload_access_levels(self, team: Team, resource: APIScopeObject, resource_id: Optional[str] = None) -> None: + """ + Checking permissions can involve multiple queries to AccessControl e.g. project level, global resource level, and object level + As we can know this upfront, we can optimize this by loading all the controls we will need upfront. + """ + # Question - are we fundamentally loading every access control for the given resource? If so should we accept that fact and just load them all? + # doing all additional filtering in memory? + + filter_groups: list[dict] = [] + + filter_groups.append(self._access_controls_filters_for_object(resource="project", resource_id=str(team.id))) + filter_groups.append(self._access_controls_filters_for_resource(resource)) + + if resource_id: + filter_groups.append(self._access_controls_filters_for_object(resource, resource_id=resource_id)) + else: + filter_groups.append(self._access_controls_filters_for_queryset(resource)) + + q = Q() + for filters in filter_groups: + q = q | self._filter_options(filters) + + access_controls = list(AccessControl.objects.filter(q)) + self._fill_filters_cache(filter_groups, access_controls) + + # Object level - checking conditions for specific items + def access_level_for_object( + self, obj: Model, resource: Optional[APIScopeObject] = None, explicit=False + ) -> Optional[AccessControlLevel]: + """ + Access levels are strings - the order of which is determined at run time. + We find all relevant access controls and then return the highest value + """ + + resource = resource or model_to_resource(obj) + org_membership = self._organization_membership + + if not resource or not org_membership: + return None + + # Creators always have highest access + if getattr(obj, "created_by", None) == self._user: + return highest_access_level(resource) + + # Org admins always have highest access + if org_membership.level >= OrganizationMembership.Level.ADMIN: + return highest_access_level(resource) + + if resource == "organization": + # Organization access is controlled via membership level only + if org_membership.level >= OrganizationMembership.Level.ADMIN: + return "admin" + return "member" + + # If access controls aren't supported, then we return the default access level + if not self.access_controls_supported: + return default_access_level(resource) if not explicit else None + + filters = self._access_controls_filters_for_object(resource, str(obj.id)) # type: ignore + access_controls = self._get_access_controls(filters) + + # If there is no specified controls on the resource then we return the default access level + if not access_controls: + return default_access_level(resource) if not explicit else None + + # If there are access controls we pick the highest level the user has + return max( + access_controls, + key=lambda access_control: ordered_access_levels(resource).index(access_control.access_level), + ).access_level + + def check_access_level_for_object( + self, obj: Model, required_level: AccessControlLevel, explicit=False + ) -> Optional[bool]: + """ + Entry point for all permissions around a specific object. + If any of the access controls have the same or higher level than the requested level, return True. + + Returns true or false if access controls are applied, otherwise None + """ + + resource = model_to_resource(obj) + if not resource: + # Permissions do not apply to models without a related scope + return True + + access_level = self.access_level_for_object(obj, resource, explicit=explicit) + + if not access_level: + return False + + # If no access control exists + return access_level_satisfied_for_resource(resource, access_level, required_level) + + def check_can_modify_access_levels_for_object(self, obj: Model) -> Optional[bool]: + """ + Special case for checking if the user can modify the access levels for an object. + Unlike check_access_level_for_object, this requires that one of these conditions is true: + 1. The user is the creator of the object + 2. The user is explicitly a project admin + 2. The user is an org admin + """ + + if getattr(obj, "created_by", None) == self._user: + # TODO: Should this always be the case, even for projects? + return True + + # If they aren't the creator then they need to be a project admin or org admin + # TRICKY: If self._team isn't set, this is likely called for a Team itself so we pass in the object + return self.check_access_level_for_object(self._team or obj, required_level="admin", explicit=True) + + # Resource level - checking conditions for the resource type + def access_level_for_resource(self, resource: APIScopeObject) -> Optional[AccessControlLevel]: + """ + Access levels are strings - the order of which is determined at run time. + We find all relevant access controls and then return the highest value + """ + + org_membership = self._organization_membership + + if not resource or not org_membership: + # In any of these cases, we can't determine the access level + return None + + # Org admins always have resource level access + if org_membership.level >= OrganizationMembership.Level.ADMIN: + return highest_access_level(resource) + + if not self.access_controls_supported: + # If access controls aren't supported, then return the default access level + return default_access_level(resource) + + filters = self._access_controls_filters_for_resource(resource) + access_controls = self._get_access_controls(filters) + + if not access_controls: + return default_access_level(resource) + + return max( + access_controls, + key=lambda access_control: ordered_access_levels(resource).index(access_control.access_level), + ).access_level + + def check_access_level_for_resource(self, resource: APIScopeObject, required_level: AccessControlLevel) -> bool: + access_level = self.access_level_for_resource(resource) + + if not access_level: + return False + + return access_level_satisfied_for_resource(resource, access_level, required_level) + + def filter_queryset_by_access_level(self, queryset: QuerySet, include_all_if_admin=False) -> QuerySet: + # Find all items related to the queryset model that have access controls such that the effective level for the user is "none" + # and exclude them from the queryset + + model = cast(Model, queryset.model) + resource = model_to_resource(model) + + if not resource: + return queryset + + if include_all_if_admin: + org_membership = self._organization_membership + + if org_membership and org_membership.level >= OrganizationMembership.Level.ADMIN: + return queryset + + model_has_creator = hasattr(model, "created_by") + + filters = self._access_controls_filters_for_queryset(resource) + access_controls = self._get_access_controls(filters) + + blocked_resource_ids: set[str] = set() + resource_id_access_levels: dict[str, list[str]] = {} + + for access_control in access_controls: + resource_id_access_levels.setdefault(access_control.resource_id, []).append(access_control.access_level) + + for resource_id, access_levels in resource_id_access_levels.items(): + # Check if every access level is "none" + if all(access_level == NO_ACCESS_LEVEL for access_level in access_levels): + blocked_resource_ids.add(resource_id) + + # Filter the queryset based on the access controls + if blocked_resource_ids: + # Filter out any IDs where the user is not the creator and the id is blocked + if model_has_creator: + queryset = queryset.exclude(Q(id__in=blocked_resource_ids) & ~Q(created_by=self._user)) + else: + queryset = queryset.exclude(id__in=blocked_resource_ids) + + return queryset + + +class UserAccessControlSerializerMixin(serializers.Serializer): + """ + Mixin for serializers to add user access control fields + """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self._preloaded_access_controls = False + + user_access_level = serializers.SerializerMethodField( + read_only=True, + help_text="The effective access level the user has for this object", + ) + + @property + def user_access_control(self) -> Optional[UserAccessControl]: + # NOTE: The user_access_control is typically on the view but in specific cases such as the posthog_app_context it is set at the context level + if "user_access_control" in self.context: + # Get it directly from the context + return self.context["user_access_control"] + elif hasattr(self.context.get("view", None), "user_access_control"): + # Otherwise from the view (the default case) + return self.context["view"].user_access_control + else: + user = cast(User | AnonymousUser, self.context["request"].user) + # The user could be anonymous - if so there is no access control to be used + + if user.is_anonymous: + return None + + user = cast(User, user) + + return UserAccessControl(user, organization_id=str(user.current_organization_id)) + + def get_user_access_level(self, obj: Model) -> Optional[str]: + if not self.user_access_control: + return None + + # Check if self.instance is a list - if so we want to preload the user access controls + if not self._preloaded_access_controls and isinstance(self.instance, list): + self.user_access_control.preload_object_access_controls(self.instance) + self._preloaded_access_controls = True + + return self.user_access_control.access_level_for_object(obj) diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr index 220b74452fa05..55770386bd565 100644 --- a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr +++ b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr @@ -549,7 +549,9 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- # name: TestSessionRecordings.test_get_session_recordings.2 @@ -623,6 +625,84 @@ ''' # --- # name: TestSessionRecordings.test_get_session_recordings.20 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '413' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '413' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_get_session_recordings.21 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestSessionRecordings.test_get_session_recordings.22 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -648,7 +728,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_get_session_recordings.21 +# name: TestSessionRecordings.test_get_session_recordings.23 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -661,7 +741,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_get_session_recordings.22 +# name: TestSessionRecordings.test_get_session_recordings.24 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -682,7 +762,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_get_session_recordings.23 +# name: TestSessionRecordings.test_get_session_recordings.25 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -755,7 +835,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_get_session_recordings.24 +# name: TestSessionRecordings.test_get_session_recordings.26 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -774,7 +854,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_get_session_recordings.25 +# name: TestSessionRecordings.test_get_session_recordings.27 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -787,7 +867,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_get_session_recordings.26 +# name: TestSessionRecordings.test_get_session_recordings.28 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -808,7 +888,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_get_session_recordings.27 +# name: TestSessionRecordings.test_get_session_recordings.29 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -881,53 +961,6 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_get_session_recordings.28 - ''' - SELECT "posthog_datawarehousejoin"."created_by_id", - "posthog_datawarehousejoin"."created_at", - "posthog_datawarehousejoin"."deleted", - "posthog_datawarehousejoin"."deleted_at", - "posthog_datawarehousejoin"."id", - "posthog_datawarehousejoin"."team_id", - "posthog_datawarehousejoin"."source_table_name", - "posthog_datawarehousejoin"."source_table_key", - "posthog_datawarehousejoin"."joining_table_name", - "posthog_datawarehousejoin"."joining_table_key", - "posthog_datawarehousejoin"."field_name" - FROM "posthog_datawarehousejoin" - WHERE ("posthog_datawarehousejoin"."team_id" = 99999 - AND NOT ("posthog_datawarehousejoin"."deleted" - AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) - ''' -# --- -# name: TestSessionRecordings.test_get_session_recordings.29 - ''' - SELECT "posthog_sessionrecording"."id", - "posthog_sessionrecording"."session_id", - "posthog_sessionrecording"."team_id", - "posthog_sessionrecording"."created_at", - "posthog_sessionrecording"."deleted", - "posthog_sessionrecording"."object_storage_path", - "posthog_sessionrecording"."distinct_id", - "posthog_sessionrecording"."duration", - "posthog_sessionrecording"."active_seconds", - "posthog_sessionrecording"."inactive_seconds", - "posthog_sessionrecording"."start_time", - "posthog_sessionrecording"."end_time", - "posthog_sessionrecording"."click_count", - "posthog_sessionrecording"."keypress_count", - "posthog_sessionrecording"."mouse_activity_count", - "posthog_sessionrecording"."console_log_count", - "posthog_sessionrecording"."console_warn_count", - "posthog_sessionrecording"."console_error_count", - "posthog_sessionrecording"."start_url", - "posthog_sessionrecording"."storage_version" - FROM "posthog_sessionrecording" - WHERE ("posthog_sessionrecording"."session_id" IN ('test_get_session_recordings-1', - 'test_get_session_recordings-2') - AND "posthog_sessionrecording"."team_id" = 99999) - ''' -# --- # name: TestSessionRecordings.test_get_session_recordings.3 ''' SELECT "posthog_team"."id", @@ -999,6 +1032,53 @@ ''' # --- # name: TestSessionRecordings.test_get_session_recordings.30 + ''' + SELECT "posthog_datawarehousejoin"."created_by_id", + "posthog_datawarehousejoin"."created_at", + "posthog_datawarehousejoin"."deleted", + "posthog_datawarehousejoin"."deleted_at", + "posthog_datawarehousejoin"."id", + "posthog_datawarehousejoin"."team_id", + "posthog_datawarehousejoin"."source_table_name", + "posthog_datawarehousejoin"."source_table_key", + "posthog_datawarehousejoin"."joining_table_name", + "posthog_datawarehousejoin"."joining_table_key", + "posthog_datawarehousejoin"."field_name" + FROM "posthog_datawarehousejoin" + WHERE ("posthog_datawarehousejoin"."team_id" = 99999 + AND NOT ("posthog_datawarehousejoin"."deleted" + AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) + ''' +# --- +# name: TestSessionRecordings.test_get_session_recordings.31 + ''' + SELECT "posthog_sessionrecording"."id", + "posthog_sessionrecording"."session_id", + "posthog_sessionrecording"."team_id", + "posthog_sessionrecording"."created_at", + "posthog_sessionrecording"."deleted", + "posthog_sessionrecording"."object_storage_path", + "posthog_sessionrecording"."distinct_id", + "posthog_sessionrecording"."duration", + "posthog_sessionrecording"."active_seconds", + "posthog_sessionrecording"."inactive_seconds", + "posthog_sessionrecording"."start_time", + "posthog_sessionrecording"."end_time", + "posthog_sessionrecording"."click_count", + "posthog_sessionrecording"."keypress_count", + "posthog_sessionrecording"."mouse_activity_count", + "posthog_sessionrecording"."console_log_count", + "posthog_sessionrecording"."console_warn_count", + "posthog_sessionrecording"."console_error_count", + "posthog_sessionrecording"."start_url", + "posthog_sessionrecording"."storage_version" + FROM "posthog_sessionrecording" + WHERE ("posthog_sessionrecording"."session_id" IN ('test_get_session_recordings-1', + 'test_get_session_recordings-2') + AND "posthog_sessionrecording"."team_id" = 99999) + ''' +# --- +# name: TestSessionRecordings.test_get_session_recordings.32 ''' SELECT "posthog_sessionrecordingviewed"."session_id" FROM "posthog_sessionrecordingviewed" @@ -1006,7 +1086,7 @@ AND "posthog_sessionrecordingviewed"."user_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_get_session_recordings.31 +# name: TestSessionRecordings.test_get_session_recordings.33 ''' SELECT "posthog_persondistinctid"."id", "posthog_persondistinctid"."team_id", @@ -1547,347 +1627,18 @@ # --- # name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.10 ''' - SELECT "posthog_datawarehousetable"."created_by_id", - "posthog_datawarehousetable"."created_at", - "posthog_datawarehousetable"."updated_at", - "posthog_datawarehousetable"."deleted", - "posthog_datawarehousetable"."deleted_at", - "posthog_datawarehousetable"."id", - "posthog_datawarehousetable"."name", - "posthog_datawarehousetable"."format", - "posthog_datawarehousetable"."team_id", - "posthog_datawarehousetable"."url_pattern", - "posthog_datawarehousetable"."credential_id", - "posthog_datawarehousetable"."external_data_source_id", - "posthog_datawarehousetable"."columns", - "posthog_datawarehousetable"."row_count", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in", - "posthog_datawarehousecredential"."created_by_id", - "posthog_datawarehousecredential"."created_at", - "posthog_datawarehousecredential"."id", - "posthog_datawarehousecredential"."access_key", - "posthog_datawarehousecredential"."access_secret", - "posthog_datawarehousecredential"."team_id", - "posthog_externaldatasource"."created_by_id", - "posthog_externaldatasource"."created_at", - "posthog_externaldatasource"."updated_at", - "posthog_externaldatasource"."deleted", - "posthog_externaldatasource"."deleted_at", - "posthog_externaldatasource"."id", - "posthog_externaldatasource"."source_id", - "posthog_externaldatasource"."connection_id", - "posthog_externaldatasource"."destination_id", - "posthog_externaldatasource"."team_id", - "posthog_externaldatasource"."sync_frequency", - "posthog_externaldatasource"."status", - "posthog_externaldatasource"."source_type", - "posthog_externaldatasource"."job_inputs", - "posthog_externaldatasource"."are_tables_created", - "posthog_externaldatasource"."prefix" - FROM "posthog_datawarehousetable" - LEFT OUTER JOIN "posthog_user" ON ("posthog_datawarehousetable"."created_by_id" = "posthog_user"."id") - LEFT OUTER JOIN "posthog_datawarehousecredential" ON ("posthog_datawarehousetable"."credential_id" = "posthog_datawarehousecredential"."id") - LEFT OUTER JOIN "posthog_externaldatasource" ON ("posthog_datawarehousetable"."external_data_source_id" = "posthog_externaldatasource"."id") - WHERE ("posthog_datawarehousetable"."team_id" = 99999 - AND NOT ("posthog_datawarehousetable"."deleted" - AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) + SELECT "posthog_grouptypemapping"."id", + "posthog_grouptypemapping"."team_id", + "posthog_grouptypemapping"."project_id", + "posthog_grouptypemapping"."group_type", + "posthog_grouptypemapping"."group_type_index", + "posthog_grouptypemapping"."name_singular", + "posthog_grouptypemapping"."name_plural" + FROM "posthog_grouptypemapping" + WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- # name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.100 - ''' - SELECT "posthog_sessionrecording"."id", - "posthog_sessionrecording"."session_id", - "posthog_sessionrecording"."team_id", - "posthog_sessionrecording"."created_at", - "posthog_sessionrecording"."deleted", - "posthog_sessionrecording"."object_storage_path", - "posthog_sessionrecording"."distinct_id", - "posthog_sessionrecording"."duration", - "posthog_sessionrecording"."active_seconds", - "posthog_sessionrecording"."inactive_seconds", - "posthog_sessionrecording"."start_time", - "posthog_sessionrecording"."end_time", - "posthog_sessionrecording"."click_count", - "posthog_sessionrecording"."keypress_count", - "posthog_sessionrecording"."mouse_activity_count", - "posthog_sessionrecording"."console_log_count", - "posthog_sessionrecording"."console_warn_count", - "posthog_sessionrecording"."console_error_count", - "posthog_sessionrecording"."start_url", - "posthog_sessionrecording"."storage_version" - FROM "posthog_sessionrecording" - WHERE ("posthog_sessionrecording"."session_id" IN ('1', - '2', - '3', - '4', - '5') - AND "posthog_sessionrecording"."team_id" = 99999) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.101 - ''' - SELECT "posthog_sessionrecordingviewed"."session_id" - FROM "posthog_sessionrecordingviewed" - WHERE ("posthog_sessionrecordingviewed"."team_id" = 99999 - AND "posthog_sessionrecordingviewed"."user_id" = 99999) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.102 - ''' - SELECT "posthog_persondistinctid"."id", - "posthog_persondistinctid"."team_id", - "posthog_persondistinctid"."person_id", - "posthog_persondistinctid"."distinct_id", - "posthog_persondistinctid"."version", - "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_persondistinctid" - INNER JOIN "posthog_person" ON ("posthog_persondistinctid"."person_id" = "posthog_person"."id") - WHERE ("posthog_persondistinctid"."distinct_id" IN ('user1', - 'user2', - 'user3', - 'user4', - 'user5') - AND "posthog_persondistinctid"."team_id" = 99999) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.103 - ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.104 - ''' - SELECT "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_person" - INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user6' - AND "posthog_persondistinctid"."team_id" = 99999) - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.105 - ''' - SELECT "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_person" - INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user6' - AND "posthog_persondistinctid"."team_id" = 99999) - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.106 - ''' - SELECT "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_user" - WHERE "posthog_user"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.107 - ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.108 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -1916,12 +1667,66 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.109 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.101 ''' - SELECT "posthog_organization"."id", + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.102 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", "posthog_organization"."name", "posthog_organization"."slug", "posthog_organization"."logo_media_id", @@ -1940,31 +1745,38 @@ "posthog_organization"."setup_section_2_completed", "posthog_organization"."personalization", "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.11 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.103 ''' - SELECT "posthog_datawarehousejoin"."created_by_id", - "posthog_datawarehousejoin"."created_at", - "posthog_datawarehousejoin"."deleted", - "posthog_datawarehousejoin"."deleted_at", - "posthog_datawarehousejoin"."id", - "posthog_datawarehousejoin"."team_id", - "posthog_datawarehousejoin"."source_table_name", - "posthog_datawarehousejoin"."source_table_key", - "posthog_datawarehousejoin"."joining_table_name", - "posthog_datawarehousejoin"."joining_table_key", - "posthog_datawarehousejoin"."field_name" - FROM "posthog_datawarehousejoin" - WHERE ("posthog_datawarehousejoin"."team_id" = 99999 - AND NOT ("posthog_datawarehousejoin"."deleted" - AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.110 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.104 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -1977,7 +1789,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.111 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.105 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -1998,7 +1810,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.112 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.106 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -2071,7 +1883,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.113 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.107 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -2090,7 +1902,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.114 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.108 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -2103,7 +1915,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.115 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.109 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -2124,7 +1936,28 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.116 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.11 + ''' + SELECT "posthog_datawarehousesavedquery"."created_by_id", + "posthog_datawarehousesavedquery"."created_at", + "posthog_datawarehousesavedquery"."deleted", + "posthog_datawarehousesavedquery"."deleted_at", + "posthog_datawarehousesavedquery"."id", + "posthog_datawarehousesavedquery"."name", + "posthog_datawarehousesavedquery"."team_id", + "posthog_datawarehousesavedquery"."columns", + "posthog_datawarehousesavedquery"."external_tables", + "posthog_datawarehousesavedquery"."query", + "posthog_datawarehousesavedquery"."status", + "posthog_datawarehousesavedquery"."last_run_at", + "posthog_datawarehousesavedquery"."table_id" + FROM "posthog_datawarehousesavedquery" + WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 + AND NOT ("posthog_datawarehousesavedquery"."deleted" + AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.110 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -2197,7 +2030,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.117 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.111 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -2216,7 +2049,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.118 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.112 ''' SELECT "posthog_sessionrecording"."id", "posthog_sessionrecording"."session_id", @@ -2243,20 +2076,11 @@ '2', '3', '4', - '5', - '6') + '5') AND "posthog_sessionrecording"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.119 - ''' - SELECT "posthog_sessionrecordingviewed"."session_id" - FROM "posthog_sessionrecordingviewed" - WHERE ("posthog_sessionrecordingviewed"."team_id" = 99999 - AND "posthog_sessionrecordingviewed"."user_id" = 99999) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.12 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.113 ''' SELECT "posthog_sessionrecordingviewed"."session_id" FROM "posthog_sessionrecordingviewed" @@ -2264,7 +2088,7 @@ AND "posthog_sessionrecordingviewed"."user_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.120 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.114 ''' SELECT "posthog_persondistinctid"."id", "posthog_persondistinctid"."team_id", @@ -2287,12 +2111,11 @@ 'user2', 'user3', 'user4', - 'user5', - 'user6') + 'user5') AND "posthog_persondistinctid"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.121 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.115 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -2362,7 +2185,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.122 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.116 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -2376,12 +2199,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user7' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user6' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.123 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.117 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -2395,12 +2218,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user7' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user6' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.124 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.118 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -2432,7 +2255,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.125 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.119 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -2495,7 +2318,160 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.126 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.12 + ''' + SELECT "posthog_datawarehousetable"."created_by_id", + "posthog_datawarehousetable"."created_at", + "posthog_datawarehousetable"."updated_at", + "posthog_datawarehousetable"."deleted", + "posthog_datawarehousetable"."deleted_at", + "posthog_datawarehousetable"."id", + "posthog_datawarehousetable"."name", + "posthog_datawarehousetable"."format", + "posthog_datawarehousetable"."team_id", + "posthog_datawarehousetable"."url_pattern", + "posthog_datawarehousetable"."credential_id", + "posthog_datawarehousetable"."external_data_source_id", + "posthog_datawarehousetable"."columns", + "posthog_datawarehousetable"."row_count", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in", + "posthog_datawarehousecredential"."created_by_id", + "posthog_datawarehousecredential"."created_at", + "posthog_datawarehousecredential"."id", + "posthog_datawarehousecredential"."access_key", + "posthog_datawarehousecredential"."access_secret", + "posthog_datawarehousecredential"."team_id", + "posthog_externaldatasource"."created_by_id", + "posthog_externaldatasource"."created_at", + "posthog_externaldatasource"."updated_at", + "posthog_externaldatasource"."deleted", + "posthog_externaldatasource"."deleted_at", + "posthog_externaldatasource"."id", + "posthog_externaldatasource"."source_id", + "posthog_externaldatasource"."connection_id", + "posthog_externaldatasource"."destination_id", + "posthog_externaldatasource"."team_id", + "posthog_externaldatasource"."sync_frequency", + "posthog_externaldatasource"."status", + "posthog_externaldatasource"."source_type", + "posthog_externaldatasource"."job_inputs", + "posthog_externaldatasource"."are_tables_created", + "posthog_externaldatasource"."prefix" + FROM "posthog_datawarehousetable" + LEFT OUTER JOIN "posthog_user" ON ("posthog_datawarehousetable"."created_by_id" = "posthog_user"."id") + LEFT OUTER JOIN "posthog_datawarehousecredential" ON ("posthog_datawarehousetable"."credential_id" = "posthog_datawarehousecredential"."id") + LEFT OUTER JOIN "posthog_externaldatasource" ON ("posthog_datawarehousetable"."external_data_source_id" = "posthog_externaldatasource"."id") + WHERE ("posthog_datawarehousetable"."team_id" = 99999 + AND NOT ("posthog_datawarehousetable"."deleted" + AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.120 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.121 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.122 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -2527,7 +2503,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.127 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.123 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -2553,7 +2529,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.128 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.124 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -2566,7 +2542,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.129 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.125 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -2587,77 +2563,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.13 - ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.130 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.126 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -2730,7 +2636,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.131 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.127 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -2749,7 +2655,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.132 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.128 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -2762,7 +2668,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.133 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.129 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -2783,7 +2689,26 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.134 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.13 + ''' + SELECT "posthog_datawarehousejoin"."created_by_id", + "posthog_datawarehousejoin"."created_at", + "posthog_datawarehousejoin"."deleted", + "posthog_datawarehousejoin"."deleted_at", + "posthog_datawarehousejoin"."id", + "posthog_datawarehousejoin"."team_id", + "posthog_datawarehousejoin"."source_table_name", + "posthog_datawarehousejoin"."source_table_key", + "posthog_datawarehousejoin"."joining_table_name", + "posthog_datawarehousejoin"."joining_table_key", + "posthog_datawarehousejoin"."field_name" + FROM "posthog_datawarehousejoin" + WHERE ("posthog_datawarehousejoin"."team_id" = 99999 + AND NOT ("posthog_datawarehousejoin"."deleted" + AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.130 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -2856,7 +2781,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.135 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.131 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -2875,7 +2800,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.136 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.132 ''' SELECT "posthog_sessionrecording"."id", "posthog_sessionrecording"."session_id", @@ -2903,12 +2828,11 @@ '3', '4', '5', - '6', - '7') + '6') AND "posthog_sessionrecording"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.137 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.133 ''' SELECT "posthog_sessionrecordingviewed"."session_id" FROM "posthog_sessionrecordingviewed" @@ -2916,7 +2840,7 @@ AND "posthog_sessionrecordingviewed"."user_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.138 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.134 ''' SELECT "posthog_persondistinctid"."id", "posthog_persondistinctid"."team_id", @@ -2940,12 +2864,11 @@ 'user3', 'user4', 'user5', - 'user6', - 'user7') + 'user6') AND "posthog_persondistinctid"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.139 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.135 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3015,26 +2938,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.14 - ''' - SELECT "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_person" - INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user1' - AND "posthog_persondistinctid"."team_id" = 99999) - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.140 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.136 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -3048,12 +2952,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user8' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user7' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.141 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.137 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -3067,12 +2971,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user8' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user7' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.142 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.138 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -3104,7 +3008,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.143 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.139 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3167,7 +3071,95 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.144 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.14 + ''' + SELECT "posthog_sessionrecordingviewed"."session_id" + FROM "posthog_sessionrecordingviewed" + WHERE ("posthog_sessionrecordingviewed"."team_id" = 99999 + AND "posthog_sessionrecordingviewed"."user_id" = 99999) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.140 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.141 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.142 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -3199,7 +3191,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.145 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.143 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -3225,7 +3217,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.146 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.144 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -3238,7 +3230,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.147 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.145 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -3259,7 +3251,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.148 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.146 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -3332,7 +3324,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.149 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.147 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -3351,26 +3343,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.15 - ''' - SELECT "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_person" - INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user1' - AND "posthog_persondistinctid"."team_id" = 99999) - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.150 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.148 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -3383,7 +3356,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.151 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.149 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -3404,63 +3377,133 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.152 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.15 ''' - SELECT "posthog_datawarehousetable"."created_by_id", - "posthog_datawarehousetable"."created_at", - "posthog_datawarehousetable"."updated_at", - "posthog_datawarehousetable"."deleted", - "posthog_datawarehousetable"."deleted_at", - "posthog_datawarehousetable"."id", - "posthog_datawarehousetable"."name", - "posthog_datawarehousetable"."format", - "posthog_datawarehousetable"."team_id", - "posthog_datawarehousetable"."url_pattern", - "posthog_datawarehousetable"."credential_id", - "posthog_datawarehousetable"."external_data_source_id", - "posthog_datawarehousetable"."columns", - "posthog_datawarehousetable"."row_count", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in", - "posthog_datawarehousecredential"."created_by_id", - "posthog_datawarehousecredential"."created_at", - "posthog_datawarehousecredential"."id", - "posthog_datawarehousecredential"."access_key", - "posthog_datawarehousecredential"."access_secret", - "posthog_datawarehousecredential"."team_id", - "posthog_externaldatasource"."created_by_id", - "posthog_externaldatasource"."created_at", - "posthog_externaldatasource"."updated_at", - "posthog_externaldatasource"."deleted", - "posthog_externaldatasource"."deleted_at", - "posthog_externaldatasource"."id", - "posthog_externaldatasource"."source_id", - "posthog_externaldatasource"."connection_id", - "posthog_externaldatasource"."destination_id", + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.150 + ''' + SELECT "posthog_datawarehousetable"."created_by_id", + "posthog_datawarehousetable"."created_at", + "posthog_datawarehousetable"."updated_at", + "posthog_datawarehousetable"."deleted", + "posthog_datawarehousetable"."deleted_at", + "posthog_datawarehousetable"."id", + "posthog_datawarehousetable"."name", + "posthog_datawarehousetable"."format", + "posthog_datawarehousetable"."team_id", + "posthog_datawarehousetable"."url_pattern", + "posthog_datawarehousetable"."credential_id", + "posthog_datawarehousetable"."external_data_source_id", + "posthog_datawarehousetable"."columns", + "posthog_datawarehousetable"."row_count", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in", + "posthog_datawarehousecredential"."created_by_id", + "posthog_datawarehousecredential"."created_at", + "posthog_datawarehousecredential"."id", + "posthog_datawarehousecredential"."access_key", + "posthog_datawarehousecredential"."access_secret", + "posthog_datawarehousecredential"."team_id", + "posthog_externaldatasource"."created_by_id", + "posthog_externaldatasource"."created_at", + "posthog_externaldatasource"."updated_at", + "posthog_externaldatasource"."deleted", + "posthog_externaldatasource"."deleted_at", + "posthog_externaldatasource"."id", + "posthog_externaldatasource"."source_id", + "posthog_externaldatasource"."connection_id", + "posthog_externaldatasource"."destination_id", "posthog_externaldatasource"."team_id", "posthog_externaldatasource"."sync_frequency", "posthog_externaldatasource"."status", @@ -3477,7 +3520,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.153 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.151 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -3496,7 +3539,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.154 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.152 ''' SELECT "posthog_sessionrecording"."id", "posthog_sessionrecording"."session_id", @@ -3525,12 +3568,11 @@ '4', '5', '6', - '7', - '8') + '7') AND "posthog_sessionrecording"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.155 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.153 ''' SELECT "posthog_sessionrecordingviewed"."session_id" FROM "posthog_sessionrecordingviewed" @@ -3538,7 +3580,7 @@ AND "posthog_sessionrecordingviewed"."user_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.156 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.154 ''' SELECT "posthog_persondistinctid"."id", "posthog_persondistinctid"."team_id", @@ -3563,12 +3605,11 @@ 'user4', 'user5', 'user6', - 'user7', - 'user8') + 'user7') AND "posthog_persondistinctid"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.157 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.155 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3638,7 +3679,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.158 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.156 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -3652,12 +3693,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user9' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user8' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.159 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.157 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -3671,44 +3712,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user9' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user8' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.16 - ''' - SELECT "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_user" - WHERE "posthog_user"."id" = 99999 - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.160 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.158 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -3740,7 +3749,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.161 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.159 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -3803,6 +3812,105 @@ LIMIT 21 ''' # --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.16 + ''' + SELECT "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_person" + INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") + WHERE ("posthog_persondistinctid"."distinct_id" = 'user1' + AND "posthog_persondistinctid"."team_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.160 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.161 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- # name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.162 ''' SELECT "posthog_organizationmembership"."id", @@ -4023,64 +4131,20 @@ # --- # name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.17 ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 + SELECT "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_person" + INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") + WHERE ("posthog_persondistinctid"."distinct_id" = 'user1' + AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- @@ -4206,8 +4270,7 @@ '5', '6', '7', - '8', - '9') + '8') AND "posthog_sessionrecording"."team_id" = 99999) ''' # --- @@ -4245,8 +4308,7 @@ 'user5', 'user6', 'user7', - 'user8', - 'user9') + 'user8') AND "posthog_persondistinctid"."team_id" = 99999) ''' # --- @@ -4334,7 +4396,7 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user10' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user9' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' @@ -4353,7 +4415,7 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user10' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user9' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' @@ -4454,6 +4516,38 @@ ''' # --- # name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.18 + ''' + SELECT "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in" + FROM "posthog_user" + WHERE "posthog_user"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.180 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -4482,10 +4576,58 @@ "posthog_organization"."domain_whitelist" FROM "posthog_organizationmembership" INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.180 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.181 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.182 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -4517,7 +4659,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.181 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.183 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -4543,7 +4685,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.182 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.184 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -4556,7 +4698,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.183 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.185 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -4577,7 +4719,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.184 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.186 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -4650,7 +4792,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.185 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.187 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -4669,7 +4811,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.186 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.188 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -4682,7 +4824,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.187 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.189 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -4703,7 +4845,70 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.188 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.19 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.190 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -4776,7 +4981,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.189 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.191 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -4795,33 +5000,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.19 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.190 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.192 ''' SELECT "posthog_sessionrecording"."id", "posthog_sessionrecording"."session_id", @@ -4845,7 +5024,6 @@ "posthog_sessionrecording"."storage_version" FROM "posthog_sessionrecording" WHERE ("posthog_sessionrecording"."session_id" IN ('1', - '10', '2', '3', '4', @@ -4857,7 +5035,7 @@ AND "posthog_sessionrecording"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.191 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.193 ''' SELECT "posthog_sessionrecordingviewed"."session_id" FROM "posthog_sessionrecordingviewed" @@ -4865,7 +5043,7 @@ AND "posthog_sessionrecordingviewed"."user_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.192 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.194 ''' SELECT "posthog_persondistinctid"."id", "posthog_persondistinctid"."team_id", @@ -4885,7 +5063,6 @@ FROM "posthog_persondistinctid" INNER JOIN "posthog_person" ON ("posthog_persondistinctid"."person_id" = "posthog_person"."id") WHERE ("posthog_persondistinctid"."distinct_id" IN ('user1', - 'user10', 'user2', 'user3', 'user4', @@ -4897,89 +5074,117 @@ AND "posthog_persondistinctid"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.2 - ''' - SELECT "posthog_organizationmembership"."id", - "posthog_organizationmembership"."organization_id", - "posthog_organizationmembership"."user_id", - "posthog_organizationmembership"."level", - "posthog_organizationmembership"."joined_at", - "posthog_organizationmembership"."updated_at", - "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organizationmembership" - INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") - WHERE "posthog_organizationmembership"."user_id" = 99999 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.20 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.195 ''' - SELECT "posthog_grouptypemapping"."id", - "posthog_grouptypemapping"."team_id", - "posthog_grouptypemapping"."project_id", - "posthog_grouptypemapping"."group_type", - "posthog_grouptypemapping"."group_type_index", - "posthog_grouptypemapping"."name_singular", - "posthog_grouptypemapping"."name_plural" - FROM "posthog_grouptypemapping" - WHERE "posthog_grouptypemapping"."team_id" = 99999 + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.21 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.196 ''' - SELECT "posthog_datawarehousesavedquery"."created_by_id", - "posthog_datawarehousesavedquery"."created_at", - "posthog_datawarehousesavedquery"."deleted", - "posthog_datawarehousesavedquery"."deleted_at", - "posthog_datawarehousesavedquery"."id", - "posthog_datawarehousesavedquery"."name", - "posthog_datawarehousesavedquery"."team_id", - "posthog_datawarehousesavedquery"."columns", - "posthog_datawarehousesavedquery"."external_tables", - "posthog_datawarehousesavedquery"."query", - "posthog_datawarehousesavedquery"."status", - "posthog_datawarehousesavedquery"."last_run_at", - "posthog_datawarehousesavedquery"."table_id" - FROM "posthog_datawarehousesavedquery" - WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 - AND NOT ("posthog_datawarehousesavedquery"."deleted" - AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) + SELECT "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_person" + INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") + WHERE ("posthog_persondistinctid"."distinct_id" = 'user10' + AND "posthog_persondistinctid"."team_id" = 99999) + LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.22 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.197 ''' - SELECT "posthog_datawarehousetable"."created_by_id", - "posthog_datawarehousetable"."created_at", - "posthog_datawarehousetable"."updated_at", - "posthog_datawarehousetable"."deleted", - "posthog_datawarehousetable"."deleted_at", - "posthog_datawarehousetable"."id", - "posthog_datawarehousetable"."name", - "posthog_datawarehousetable"."format", - "posthog_datawarehousetable"."team_id", - "posthog_datawarehousetable"."url_pattern", - "posthog_datawarehousetable"."credential_id", - "posthog_datawarehousetable"."external_data_source_id", - "posthog_datawarehousetable"."columns", - "posthog_datawarehousetable"."row_count", - "posthog_user"."id", + SELECT "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_person" + INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") + WHERE ("posthog_persondistinctid"."distinct_id" = 'user10' + AND "posthog_persondistinctid"."team_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.198 + ''' + SELECT "posthog_user"."id", "posthog_user"."password", "posthog_user"."last_login", "posthog_user"."first_name", @@ -4994,7 +5199,6 @@ "posthog_user"."temporary_token", "posthog_user"."distinct_id", "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", "posthog_user"."has_seen_product_intro_for", "posthog_user"."strapi_id", "posthog_user"."is_active", @@ -5004,58 +5208,282 @@ "posthog_user"."toolbar_mode", "posthog_user"."hedgehog_config", "posthog_user"."events_column_config", - "posthog_user"."email_opt_in", - "posthog_datawarehousecredential"."created_by_id", - "posthog_datawarehousecredential"."created_at", - "posthog_datawarehousecredential"."id", - "posthog_datawarehousecredential"."access_key", - "posthog_datawarehousecredential"."access_secret", - "posthog_datawarehousecredential"."team_id", - "posthog_externaldatasource"."created_by_id", - "posthog_externaldatasource"."created_at", - "posthog_externaldatasource"."updated_at", - "posthog_externaldatasource"."deleted", - "posthog_externaldatasource"."deleted_at", - "posthog_externaldatasource"."id", - "posthog_externaldatasource"."source_id", - "posthog_externaldatasource"."connection_id", - "posthog_externaldatasource"."destination_id", - "posthog_externaldatasource"."team_id", - "posthog_externaldatasource"."sync_frequency", - "posthog_externaldatasource"."status", - "posthog_externaldatasource"."source_type", - "posthog_externaldatasource"."job_inputs", - "posthog_externaldatasource"."are_tables_created", - "posthog_externaldatasource"."prefix" - FROM "posthog_datawarehousetable" - LEFT OUTER JOIN "posthog_user" ON ("posthog_datawarehousetable"."created_by_id" = "posthog_user"."id") - LEFT OUTER JOIN "posthog_datawarehousecredential" ON ("posthog_datawarehousetable"."credential_id" = "posthog_datawarehousecredential"."id") - LEFT OUTER JOIN "posthog_externaldatasource" ON ("posthog_datawarehousetable"."external_data_source_id" = "posthog_externaldatasource"."id") - WHERE ("posthog_datawarehousetable"."team_id" = 99999 - AND NOT ("posthog_datawarehousetable"."deleted" - AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) + "posthog_user"."email_opt_in" + FROM "posthog_user" + WHERE "posthog_user"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.199 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.2 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.20 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.200 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.201 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.202 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.23 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.203 ''' - SELECT "posthog_datawarehousejoin"."created_by_id", - "posthog_datawarehousejoin"."created_at", - "posthog_datawarehousejoin"."deleted", - "posthog_datawarehousejoin"."deleted_at", - "posthog_datawarehousejoin"."id", - "posthog_datawarehousejoin"."team_id", - "posthog_datawarehousejoin"."source_table_name", - "posthog_datawarehousejoin"."source_table_key", - "posthog_datawarehousejoin"."joining_table_name", - "posthog_datawarehousejoin"."joining_table_key", - "posthog_datawarehousejoin"."field_name" - FROM "posthog_datawarehousejoin" - WHERE ("posthog_datawarehousejoin"."team_id" = 99999 - AND NOT ("posthog_datawarehousejoin"."deleted" - AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.24 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.204 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -5068,7 +5496,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.25 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.205 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -5089,7 +5517,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.26 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.206 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -5162,7 +5590,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.27 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.207 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -5181,201 +5609,103 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.28 - ''' - SELECT "posthog_sessionrecording"."id", - "posthog_sessionrecording"."session_id", - "posthog_sessionrecording"."team_id", - "posthog_sessionrecording"."created_at", - "posthog_sessionrecording"."deleted", - "posthog_sessionrecording"."object_storage_path", - "posthog_sessionrecording"."distinct_id", - "posthog_sessionrecording"."duration", - "posthog_sessionrecording"."active_seconds", - "posthog_sessionrecording"."inactive_seconds", - "posthog_sessionrecording"."start_time", - "posthog_sessionrecording"."end_time", - "posthog_sessionrecording"."click_count", - "posthog_sessionrecording"."keypress_count", - "posthog_sessionrecording"."mouse_activity_count", - "posthog_sessionrecording"."console_log_count", - "posthog_sessionrecording"."console_warn_count", - "posthog_sessionrecording"."console_error_count", - "posthog_sessionrecording"."start_url", - "posthog_sessionrecording"."storage_version" - FROM "posthog_sessionrecording" - WHERE ("posthog_sessionrecording"."session_id" IN ('1') - AND "posthog_sessionrecording"."team_id" = 99999) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.29 - ''' - SELECT "posthog_sessionrecordingviewed"."session_id" - FROM "posthog_sessionrecordingviewed" - WHERE ("posthog_sessionrecordingviewed"."team_id" = 99999 - AND "posthog_sessionrecordingviewed"."user_id" = 99999) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.3 - ''' - SELECT "posthog_organization"."id", - "posthog_organization"."name", - "posthog_organization"."slug", - "posthog_organization"."logo_media_id", - "posthog_organization"."created_at", - "posthog_organization"."updated_at", - "posthog_organization"."plugins_access_level", - "posthog_organization"."for_internal_metrics", - "posthog_organization"."is_member_join_email_enabled", - "posthog_organization"."enforce_2fa", - "posthog_organization"."is_hipaa", - "posthog_organization"."customer_id", - "posthog_organization"."available_product_features", - "posthog_organization"."usage", - "posthog_organization"."never_drop_data", - "posthog_organization"."customer_trust_scores", - "posthog_organization"."setup_section_2_completed", - "posthog_organization"."personalization", - "posthog_organization"."domain_whitelist" - FROM "posthog_organization" - WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid - LIMIT 21 - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.30 - ''' - SELECT "posthog_persondistinctid"."id", - "posthog_persondistinctid"."team_id", - "posthog_persondistinctid"."person_id", - "posthog_persondistinctid"."distinct_id", - "posthog_persondistinctid"."version", - "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_persondistinctid" - INNER JOIN "posthog_person" ON ("posthog_persondistinctid"."person_id" = "posthog_person"."id") - WHERE ("posthog_persondistinctid"."distinct_id" IN ('user1') - AND "posthog_persondistinctid"."team_id" = 99999) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.31 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.208 ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."plugins_opt_in", - "posthog_team"."opt_out_capture", - "posthog_team"."event_names", - "posthog_team"."event_names_with_usage", - "posthog_team"."event_properties", - "posthog_team"."event_properties_with_usage", - "posthog_team"."event_properties_numerical", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 + SELECT "posthog_grouptypemapping"."id", + "posthog_grouptypemapping"."team_id", + "posthog_grouptypemapping"."project_id", + "posthog_grouptypemapping"."group_type", + "posthog_grouptypemapping"."group_type_index", + "posthog_grouptypemapping"."name_singular", + "posthog_grouptypemapping"."name_plural" + FROM "posthog_grouptypemapping" + WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.32 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.209 ''' - SELECT "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_person" - INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user2' - AND "posthog_persondistinctid"."team_id" = 99999) - LIMIT 21 + SELECT "posthog_datawarehousesavedquery"."created_by_id", + "posthog_datawarehousesavedquery"."created_at", + "posthog_datawarehousesavedquery"."deleted", + "posthog_datawarehousesavedquery"."deleted_at", + "posthog_datawarehousesavedquery"."id", + "posthog_datawarehousesavedquery"."name", + "posthog_datawarehousesavedquery"."team_id", + "posthog_datawarehousesavedquery"."columns", + "posthog_datawarehousesavedquery"."external_tables", + "posthog_datawarehousesavedquery"."query", + "posthog_datawarehousesavedquery"."status", + "posthog_datawarehousesavedquery"."last_run_at", + "posthog_datawarehousesavedquery"."table_id" + FROM "posthog_datawarehousesavedquery" + WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 + AND NOT ("posthog_datawarehousesavedquery"."deleted" + AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.33 - ''' - SELECT "posthog_person"."id", - "posthog_person"."created_at", - "posthog_person"."properties_last_updated_at", - "posthog_person"."properties_last_operation", - "posthog_person"."team_id", - "posthog_person"."properties", - "posthog_person"."is_user_id", - "posthog_person"."is_identified", - "posthog_person"."uuid", - "posthog_person"."version" - FROM "posthog_person" - INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user2' - AND "posthog_persondistinctid"."team_id" = 99999) - LIMIT 21 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.21 ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.34 + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.210 ''' - SELECT "posthog_user"."id", + SELECT "posthog_datawarehousetable"."created_by_id", + "posthog_datawarehousetable"."created_at", + "posthog_datawarehousetable"."updated_at", + "posthog_datawarehousetable"."deleted", + "posthog_datawarehousetable"."deleted_at", + "posthog_datawarehousetable"."id", + "posthog_datawarehousetable"."name", + "posthog_datawarehousetable"."format", + "posthog_datawarehousetable"."team_id", + "posthog_datawarehousetable"."url_pattern", + "posthog_datawarehousetable"."credential_id", + "posthog_datawarehousetable"."external_data_source_id", + "posthog_datawarehousetable"."columns", + "posthog_datawarehousetable"."row_count", + "posthog_user"."id", "posthog_user"."password", "posthog_user"."last_login", "posthog_user"."first_name", @@ -5390,6 +5720,7 @@ "posthog_user"."temporary_token", "posthog_user"."distinct_id", "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", "posthog_user"."has_seen_product_intro_for", "posthog_user"."strapi_id", "posthog_user"."is_active", @@ -5399,76 +5730,134 @@ "posthog_user"."toolbar_mode", "posthog_user"."hedgehog_config", "posthog_user"."events_column_config", - "posthog_user"."email_opt_in" - FROM "posthog_user" - WHERE "posthog_user"."id" = 99999 - LIMIT 21 + "posthog_user"."email_opt_in", + "posthog_datawarehousecredential"."created_by_id", + "posthog_datawarehousecredential"."created_at", + "posthog_datawarehousecredential"."id", + "posthog_datawarehousecredential"."access_key", + "posthog_datawarehousecredential"."access_secret", + "posthog_datawarehousecredential"."team_id", + "posthog_externaldatasource"."created_by_id", + "posthog_externaldatasource"."created_at", + "posthog_externaldatasource"."updated_at", + "posthog_externaldatasource"."deleted", + "posthog_externaldatasource"."deleted_at", + "posthog_externaldatasource"."id", + "posthog_externaldatasource"."source_id", + "posthog_externaldatasource"."connection_id", + "posthog_externaldatasource"."destination_id", + "posthog_externaldatasource"."team_id", + "posthog_externaldatasource"."sync_frequency", + "posthog_externaldatasource"."status", + "posthog_externaldatasource"."source_type", + "posthog_externaldatasource"."job_inputs", + "posthog_externaldatasource"."are_tables_created", + "posthog_externaldatasource"."prefix" + FROM "posthog_datawarehousetable" + LEFT OUTER JOIN "posthog_user" ON ("posthog_datawarehousetable"."created_by_id" = "posthog_user"."id") + LEFT OUTER JOIN "posthog_datawarehousecredential" ON ("posthog_datawarehousetable"."credential_id" = "posthog_datawarehousecredential"."id") + LEFT OUTER JOIN "posthog_externaldatasource" ON ("posthog_datawarehousetable"."external_data_source_id" = "posthog_externaldatasource"."id") + WHERE ("posthog_datawarehousetable"."team_id" = 99999 + AND NOT ("posthog_datawarehousetable"."deleted" + AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.35 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.211 ''' - SELECT "posthog_team"."id", - "posthog_team"."uuid", - "posthog_team"."organization_id", - "posthog_team"."project_id", - "posthog_team"."api_token", - "posthog_team"."app_urls", - "posthog_team"."name", - "posthog_team"."slack_incoming_webhook", - "posthog_team"."created_at", - "posthog_team"."updated_at", - "posthog_team"."anonymize_ips", - "posthog_team"."completed_snippet_onboarding", - "posthog_team"."has_completed_onboarding_for", - "posthog_team"."ingested_event", - "posthog_team"."autocapture_opt_out", - "posthog_team"."autocapture_web_vitals_opt_in", - "posthog_team"."autocapture_web_vitals_allowed_metrics", - "posthog_team"."autocapture_exceptions_opt_in", - "posthog_team"."autocapture_exceptions_errors_to_ignore", - "posthog_team"."person_processing_opt_out", - "posthog_team"."session_recording_opt_in", - "posthog_team"."session_recording_sample_rate", - "posthog_team"."session_recording_minimum_duration_milliseconds", - "posthog_team"."session_recording_linked_flag", - "posthog_team"."session_recording_network_payload_capture_config", - "posthog_team"."session_recording_url_trigger_config", - "posthog_team"."session_recording_url_blocklist_config", - "posthog_team"."session_recording_event_trigger_config", - "posthog_team"."session_replay_config", - "posthog_team"."survey_config", - "posthog_team"."capture_console_log_opt_in", - "posthog_team"."capture_performance_opt_in", - "posthog_team"."capture_dead_clicks", - "posthog_team"."surveys_opt_in", - "posthog_team"."heatmaps_opt_in", - "posthog_team"."session_recording_version", - "posthog_team"."signup_token", - "posthog_team"."is_demo", - "posthog_team"."access_control", - "posthog_team"."week_start_day", - "posthog_team"."inject_web_apps", - "posthog_team"."test_account_filters", - "posthog_team"."test_account_filters_default_checked", - "posthog_team"."path_cleaning_filters", - "posthog_team"."timezone", - "posthog_team"."data_attributes", - "posthog_team"."person_display_name_properties", - "posthog_team"."live_events_columns", - "posthog_team"."recording_domains", - "posthog_team"."primary_dashboard_id", - "posthog_team"."extra_settings", - "posthog_team"."modifiers", - "posthog_team"."correlation_config", - "posthog_team"."session_recording_retention_period_days", - "posthog_team"."external_data_workspace_id", - "posthog_team"."external_data_workspace_last_synced_at" - FROM "posthog_team" - WHERE "posthog_team"."id" = 99999 - LIMIT 21 + SELECT "posthog_datawarehousejoin"."created_by_id", + "posthog_datawarehousejoin"."created_at", + "posthog_datawarehousejoin"."deleted", + "posthog_datawarehousejoin"."deleted_at", + "posthog_datawarehousejoin"."id", + "posthog_datawarehousejoin"."team_id", + "posthog_datawarehousejoin"."source_table_name", + "posthog_datawarehousejoin"."source_table_key", + "posthog_datawarehousejoin"."joining_table_name", + "posthog_datawarehousejoin"."joining_table_key", + "posthog_datawarehousejoin"."field_name" + FROM "posthog_datawarehousejoin" + WHERE ("posthog_datawarehousejoin"."team_id" = 99999 + AND NOT ("posthog_datawarehousejoin"."deleted" + AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.36 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.212 + ''' + SELECT "posthog_sessionrecording"."id", + "posthog_sessionrecording"."session_id", + "posthog_sessionrecording"."team_id", + "posthog_sessionrecording"."created_at", + "posthog_sessionrecording"."deleted", + "posthog_sessionrecording"."object_storage_path", + "posthog_sessionrecording"."distinct_id", + "posthog_sessionrecording"."duration", + "posthog_sessionrecording"."active_seconds", + "posthog_sessionrecording"."inactive_seconds", + "posthog_sessionrecording"."start_time", + "posthog_sessionrecording"."end_time", + "posthog_sessionrecording"."click_count", + "posthog_sessionrecording"."keypress_count", + "posthog_sessionrecording"."mouse_activity_count", + "posthog_sessionrecording"."console_log_count", + "posthog_sessionrecording"."console_warn_count", + "posthog_sessionrecording"."console_error_count", + "posthog_sessionrecording"."start_url", + "posthog_sessionrecording"."storage_version" + FROM "posthog_sessionrecording" + WHERE ("posthog_sessionrecording"."session_id" IN ('1', + '10', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9') + AND "posthog_sessionrecording"."team_id" = 99999) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.213 + ''' + SELECT "posthog_sessionrecordingviewed"."session_id" + FROM "posthog_sessionrecordingviewed" + WHERE ("posthog_sessionrecordingviewed"."team_id" = 99999 + AND "posthog_sessionrecordingviewed"."user_id" = 99999) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.214 + ''' + SELECT "posthog_persondistinctid"."id", + "posthog_persondistinctid"."team_id", + "posthog_persondistinctid"."person_id", + "posthog_persondistinctid"."distinct_id", + "posthog_persondistinctid"."version", + "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_persondistinctid" + INNER JOIN "posthog_person" ON ("posthog_persondistinctid"."person_id" = "posthog_person"."id") + WHERE ("posthog_persondistinctid"."distinct_id" IN ('user1', + 'user10', + 'user2', + 'user3', + 'user4', + 'user5', + 'user6', + 'user7', + 'user8', + 'user9') + AND "posthog_persondistinctid"."team_id" = 99999) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.22 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -5500,7 +5889,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.37 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.23 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -5526,7 +5915,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.38 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.24 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -5539,7 +5928,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.39 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.25 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -5548,32 +5937,19 @@ "posthog_datawarehousesavedquery"."id", "posthog_datawarehousesavedquery"."name", "posthog_datawarehousesavedquery"."team_id", - "posthog_datawarehousesavedquery"."columns", - "posthog_datawarehousesavedquery"."external_tables", - "posthog_datawarehousesavedquery"."query", - "posthog_datawarehousesavedquery"."status", - "posthog_datawarehousesavedquery"."last_run_at", - "posthog_datawarehousesavedquery"."table_id" - FROM "posthog_datawarehousesavedquery" - WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 - AND NOT ("posthog_datawarehousesavedquery"."deleted" - AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.4 - ''' - SELECT "posthog_grouptypemapping"."id", - "posthog_grouptypemapping"."team_id", - "posthog_grouptypemapping"."project_id", - "posthog_grouptypemapping"."group_type", - "posthog_grouptypemapping"."group_type_index", - "posthog_grouptypemapping"."name_singular", - "posthog_grouptypemapping"."name_plural" - FROM "posthog_grouptypemapping" - WHERE "posthog_grouptypemapping"."team_id" = 99999 + "posthog_datawarehousesavedquery"."columns", + "posthog_datawarehousesavedquery"."external_tables", + "posthog_datawarehousesavedquery"."query", + "posthog_datawarehousesavedquery"."status", + "posthog_datawarehousesavedquery"."last_run_at", + "posthog_datawarehousesavedquery"."table_id" + FROM "posthog_datawarehousesavedquery" + WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 + AND NOT ("posthog_datawarehousesavedquery"."deleted" + AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.40 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.26 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -5646,7 +6022,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.41 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.27 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -5665,7 +6041,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.42 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.28 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -5678,7 +6054,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.43 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.29 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -5699,7 +6075,53 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.44 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.3 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.30 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -5772,7 +6194,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.45 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.31 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -5791,7 +6213,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.46 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.32 ''' SELECT "posthog_sessionrecording"."id", "posthog_sessionrecording"."session_id", @@ -5814,12 +6236,11 @@ "posthog_sessionrecording"."start_url", "posthog_sessionrecording"."storage_version" FROM "posthog_sessionrecording" - WHERE ("posthog_sessionrecording"."session_id" IN ('1', - '2') + WHERE ("posthog_sessionrecording"."session_id" IN ('1') AND "posthog_sessionrecording"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.47 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.33 ''' SELECT "posthog_sessionrecordingviewed"."session_id" FROM "posthog_sessionrecordingviewed" @@ -5827,7 +6248,7 @@ AND "posthog_sessionrecordingviewed"."user_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.48 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.34 ''' SELECT "posthog_persondistinctid"."id", "posthog_persondistinctid"."team_id", @@ -5846,12 +6267,11 @@ "posthog_person"."version" FROM "posthog_persondistinctid" INNER JOIN "posthog_person" ON ("posthog_persondistinctid"."person_id" = "posthog_person"."id") - WHERE ("posthog_persondistinctid"."distinct_id" IN ('user1', - 'user2') + WHERE ("posthog_persondistinctid"."distinct_id" IN ('user1') AND "posthog_persondistinctid"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.49 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.35 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -5921,28 +6341,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.5 - ''' - SELECT "posthog_datawarehousesavedquery"."created_by_id", - "posthog_datawarehousesavedquery"."created_at", - "posthog_datawarehousesavedquery"."deleted", - "posthog_datawarehousesavedquery"."deleted_at", - "posthog_datawarehousesavedquery"."id", - "posthog_datawarehousesavedquery"."name", - "posthog_datawarehousesavedquery"."team_id", - "posthog_datawarehousesavedquery"."columns", - "posthog_datawarehousesavedquery"."external_tables", - "posthog_datawarehousesavedquery"."query", - "posthog_datawarehousesavedquery"."status", - "posthog_datawarehousesavedquery"."last_run_at", - "posthog_datawarehousesavedquery"."table_id" - FROM "posthog_datawarehousesavedquery" - WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 - AND NOT ("posthog_datawarehousesavedquery"."deleted" - AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.50 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.36 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -5956,12 +6355,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user3' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user2' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.51 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.37 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -5975,12 +6374,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user3' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user2' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.52 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.38 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -6012,7 +6411,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.53 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.39 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -6075,7 +6474,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.54 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.4 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -6107,7 +6506,119 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.55 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.40 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.41 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.42 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.43 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -6133,7 +6644,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.56 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.44 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -6146,7 +6657,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.57 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.45 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -6167,7 +6678,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.58 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.46 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -6240,7 +6751,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.59 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.47 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -6259,80 +6770,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.6 - ''' - SELECT "posthog_datawarehousetable"."created_by_id", - "posthog_datawarehousetable"."created_at", - "posthog_datawarehousetable"."updated_at", - "posthog_datawarehousetable"."deleted", - "posthog_datawarehousetable"."deleted_at", - "posthog_datawarehousetable"."id", - "posthog_datawarehousetable"."name", - "posthog_datawarehousetable"."format", - "posthog_datawarehousetable"."team_id", - "posthog_datawarehousetable"."url_pattern", - "posthog_datawarehousetable"."credential_id", - "posthog_datawarehousetable"."external_data_source_id", - "posthog_datawarehousetable"."columns", - "posthog_datawarehousetable"."row_count", - "posthog_user"."id", - "posthog_user"."password", - "posthog_user"."last_login", - "posthog_user"."first_name", - "posthog_user"."last_name", - "posthog_user"."is_staff", - "posthog_user"."date_joined", - "posthog_user"."uuid", - "posthog_user"."current_organization_id", - "posthog_user"."current_team_id", - "posthog_user"."email", - "posthog_user"."pending_email", - "posthog_user"."temporary_token", - "posthog_user"."distinct_id", - "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", - "posthog_user"."has_seen_product_intro_for", - "posthog_user"."strapi_id", - "posthog_user"."is_active", - "posthog_user"."theme_mode", - "posthog_user"."partial_notification_settings", - "posthog_user"."anonymize_data", - "posthog_user"."toolbar_mode", - "posthog_user"."hedgehog_config", - "posthog_user"."events_column_config", - "posthog_user"."email_opt_in", - "posthog_datawarehousecredential"."created_by_id", - "posthog_datawarehousecredential"."created_at", - "posthog_datawarehousecredential"."id", - "posthog_datawarehousecredential"."access_key", - "posthog_datawarehousecredential"."access_secret", - "posthog_datawarehousecredential"."team_id", - "posthog_externaldatasource"."created_by_id", - "posthog_externaldatasource"."created_at", - "posthog_externaldatasource"."updated_at", - "posthog_externaldatasource"."deleted", - "posthog_externaldatasource"."deleted_at", - "posthog_externaldatasource"."id", - "posthog_externaldatasource"."source_id", - "posthog_externaldatasource"."connection_id", - "posthog_externaldatasource"."destination_id", - "posthog_externaldatasource"."team_id", - "posthog_externaldatasource"."sync_frequency", - "posthog_externaldatasource"."status", - "posthog_externaldatasource"."source_type", - "posthog_externaldatasource"."job_inputs", - "posthog_externaldatasource"."are_tables_created", - "posthog_externaldatasource"."prefix" - FROM "posthog_datawarehousetable" - LEFT OUTER JOIN "posthog_user" ON ("posthog_datawarehousetable"."created_by_id" = "posthog_user"."id") - LEFT OUTER JOIN "posthog_datawarehousecredential" ON ("posthog_datawarehousetable"."credential_id" = "posthog_datawarehousecredential"."id") - LEFT OUTER JOIN "posthog_externaldatasource" ON ("posthog_datawarehousetable"."external_data_source_id" = "posthog_externaldatasource"."id") - WHERE ("posthog_datawarehousetable"."team_id" = 99999 - AND NOT ("posthog_datawarehousetable"."deleted" - AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.60 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.48 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -6345,7 +6783,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.61 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.49 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -6366,7 +6804,33 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.62 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.5 + ''' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.50 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -6439,7 +6903,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.63 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.51 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -6458,7 +6922,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.64 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.52 ''' SELECT "posthog_sessionrecording"."id", "posthog_sessionrecording"."session_id", @@ -6482,12 +6946,11 @@ "posthog_sessionrecording"."storage_version" FROM "posthog_sessionrecording" WHERE ("posthog_sessionrecording"."session_id" IN ('1', - '2', - '3') + '2') AND "posthog_sessionrecording"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.65 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.53 ''' SELECT "posthog_sessionrecordingviewed"."session_id" FROM "posthog_sessionrecordingviewed" @@ -6495,7 +6958,7 @@ AND "posthog_sessionrecordingviewed"."user_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.66 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.54 ''' SELECT "posthog_persondistinctid"."id", "posthog_persondistinctid"."team_id", @@ -6515,12 +6978,11 @@ FROM "posthog_persondistinctid" INNER JOIN "posthog_person" ON ("posthog_persondistinctid"."person_id" = "posthog_person"."id") WHERE ("posthog_persondistinctid"."distinct_id" IN ('user1', - 'user2', - 'user3') + 'user2') AND "posthog_persondistinctid"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.67 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.55 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -6590,7 +7052,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.68 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.56 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -6604,12 +7066,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user4' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user3' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.69 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.57 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -6623,31 +7085,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user4' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user3' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.7 - ''' - SELECT "posthog_datawarehousejoin"."created_by_id", - "posthog_datawarehousejoin"."created_at", - "posthog_datawarehousejoin"."deleted", - "posthog_datawarehousejoin"."deleted_at", - "posthog_datawarehousejoin"."id", - "posthog_datawarehousejoin"."team_id", - "posthog_datawarehousejoin"."source_table_name", - "posthog_datawarehousejoin"."source_table_key", - "posthog_datawarehousejoin"."joining_table_name", - "posthog_datawarehousejoin"."joining_table_key", - "posthog_datawarehousejoin"."field_name" - FROM "posthog_datawarehousejoin" - WHERE ("posthog_datawarehousejoin"."team_id" = 99999 - AND NOT ("posthog_datawarehousejoin"."deleted" - AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) - ''' -# --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.70 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.58 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -6679,7 +7122,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.71 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.59 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -6742,7 +7185,100 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.72 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.6 + ''' + SELECT "posthog_grouptypemapping"."id", + "posthog_grouptypemapping"."team_id", + "posthog_grouptypemapping"."project_id", + "posthog_grouptypemapping"."group_type", + "posthog_grouptypemapping"."group_type_index", + "posthog_grouptypemapping"."name_singular", + "posthog_grouptypemapping"."name_plural" + FROM "posthog_grouptypemapping" + WHERE "posthog_grouptypemapping"."team_id" = 99999 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.60 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.61 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.62 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -6774,7 +7310,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.73 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.63 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -6800,7 +7336,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.74 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.64 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -6813,7 +7349,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.75 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.65 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -6834,7 +7370,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.76 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.66 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -6907,7 +7443,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.77 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.67 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -6926,7 +7462,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.78 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.68 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -6939,7 +7475,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.79 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.69 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -6960,20 +7496,28 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.8 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.7 ''' - SELECT "posthog_grouptypemapping"."id", - "posthog_grouptypemapping"."team_id", - "posthog_grouptypemapping"."project_id", - "posthog_grouptypemapping"."group_type", - "posthog_grouptypemapping"."group_type_index", - "posthog_grouptypemapping"."name_singular", - "posthog_grouptypemapping"."name_plural" - FROM "posthog_grouptypemapping" - WHERE "posthog_grouptypemapping"."team_id" = 99999 + SELECT "posthog_datawarehousesavedquery"."created_by_id", + "posthog_datawarehousesavedquery"."created_at", + "posthog_datawarehousesavedquery"."deleted", + "posthog_datawarehousesavedquery"."deleted_at", + "posthog_datawarehousesavedquery"."id", + "posthog_datawarehousesavedquery"."name", + "posthog_datawarehousesavedquery"."team_id", + "posthog_datawarehousesavedquery"."columns", + "posthog_datawarehousesavedquery"."external_tables", + "posthog_datawarehousesavedquery"."query", + "posthog_datawarehousesavedquery"."status", + "posthog_datawarehousesavedquery"."last_run_at", + "posthog_datawarehousesavedquery"."table_id" + FROM "posthog_datawarehousesavedquery" + WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 + AND NOT ("posthog_datawarehousesavedquery"."deleted" + AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.80 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.70 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -7046,7 +7590,7 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.81 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.71 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -7065,7 +7609,7 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.82 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.72 ''' SELECT "posthog_sessionrecording"."id", "posthog_sessionrecording"."session_id", @@ -7090,12 +7634,11 @@ FROM "posthog_sessionrecording" WHERE ("posthog_sessionrecording"."session_id" IN ('1', '2', - '3', - '4') + '3') AND "posthog_sessionrecording"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.83 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.73 ''' SELECT "posthog_sessionrecordingviewed"."session_id" FROM "posthog_sessionrecordingviewed" @@ -7103,7 +7646,7 @@ AND "posthog_sessionrecordingviewed"."user_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.84 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.74 ''' SELECT "posthog_persondistinctid"."id", "posthog_persondistinctid"."team_id", @@ -7124,12 +7667,11 @@ INNER JOIN "posthog_person" ON ("posthog_persondistinctid"."person_id" = "posthog_person"."id") WHERE ("posthog_persondistinctid"."distinct_id" IN ('user1', 'user2', - 'user3', - 'user4') + 'user3') AND "posthog_persondistinctid"."team_id" = 99999) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.85 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.75 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7199,7 +7741,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.86 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.76 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -7213,12 +7755,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user5' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user4' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.87 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.77 ''' SELECT "posthog_person"."id", "posthog_person"."created_at", @@ -7232,12 +7774,12 @@ "posthog_person"."version" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") - WHERE ("posthog_persondistinctid"."distinct_id" = 'user5' + WHERE ("posthog_persondistinctid"."distinct_id" = 'user4' AND "posthog_persondistinctid"."team_id" = 99999) LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.88 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.78 ''' SELECT "posthog_user"."id", "posthog_user"."password", @@ -7269,7 +7811,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.89 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.79 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -7332,28 +7874,160 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.9 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.8 + ''' + SELECT "posthog_datawarehousetable"."created_by_id", + "posthog_datawarehousetable"."created_at", + "posthog_datawarehousetable"."updated_at", + "posthog_datawarehousetable"."deleted", + "posthog_datawarehousetable"."deleted_at", + "posthog_datawarehousetable"."id", + "posthog_datawarehousetable"."name", + "posthog_datawarehousetable"."format", + "posthog_datawarehousetable"."team_id", + "posthog_datawarehousetable"."url_pattern", + "posthog_datawarehousetable"."credential_id", + "posthog_datawarehousetable"."external_data_source_id", + "posthog_datawarehousetable"."columns", + "posthog_datawarehousetable"."row_count", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in", + "posthog_datawarehousecredential"."created_by_id", + "posthog_datawarehousecredential"."created_at", + "posthog_datawarehousecredential"."id", + "posthog_datawarehousecredential"."access_key", + "posthog_datawarehousecredential"."access_secret", + "posthog_datawarehousecredential"."team_id", + "posthog_externaldatasource"."created_by_id", + "posthog_externaldatasource"."created_at", + "posthog_externaldatasource"."updated_at", + "posthog_externaldatasource"."deleted", + "posthog_externaldatasource"."deleted_at", + "posthog_externaldatasource"."id", + "posthog_externaldatasource"."source_id", + "posthog_externaldatasource"."connection_id", + "posthog_externaldatasource"."destination_id", + "posthog_externaldatasource"."team_id", + "posthog_externaldatasource"."sync_frequency", + "posthog_externaldatasource"."status", + "posthog_externaldatasource"."source_type", + "posthog_externaldatasource"."job_inputs", + "posthog_externaldatasource"."are_tables_created", + "posthog_externaldatasource"."prefix" + FROM "posthog_datawarehousetable" + LEFT OUTER JOIN "posthog_user" ON ("posthog_datawarehousetable"."created_by_id" = "posthog_user"."id") + LEFT OUTER JOIN "posthog_datawarehousecredential" ON ("posthog_datawarehousetable"."credential_id" = "posthog_datawarehousecredential"."id") + LEFT OUTER JOIN "posthog_externaldatasource" ON ("posthog_datawarehousetable"."external_data_source_id" = "posthog_externaldatasource"."id") + WHERE ("posthog_datawarehousetable"."team_id" = 99999 + AND NOT ("posthog_datawarehousetable"."deleted" + AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.80 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.81 ''' - SELECT "posthog_datawarehousesavedquery"."created_by_id", - "posthog_datawarehousesavedquery"."created_at", - "posthog_datawarehousesavedquery"."deleted", - "posthog_datawarehousesavedquery"."deleted_at", - "posthog_datawarehousesavedquery"."id", - "posthog_datawarehousesavedquery"."name", - "posthog_datawarehousesavedquery"."team_id", - "posthog_datawarehousesavedquery"."columns", - "posthog_datawarehousesavedquery"."external_tables", - "posthog_datawarehousesavedquery"."query", - "posthog_datawarehousesavedquery"."status", - "posthog_datawarehousesavedquery"."last_run_at", - "posthog_datawarehousesavedquery"."table_id" - FROM "posthog_datawarehousesavedquery" - WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 - AND NOT ("posthog_datawarehousesavedquery"."deleted" - AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'session_recording' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.90 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.82 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id", @@ -7385,7 +8059,7 @@ WHERE "posthog_organizationmembership"."user_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.91 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.83 ''' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -7411,7 +8085,7 @@ LIMIT 21 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.92 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.84 ''' SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", @@ -7424,7 +8098,7 @@ WHERE "posthog_grouptypemapping"."team_id" = 99999 ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.93 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.85 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", "posthog_datawarehousesavedquery"."created_at", @@ -7445,7 +8119,7 @@ AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.94 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.86 ''' SELECT "posthog_datawarehousetable"."created_by_id", "posthog_datawarehousetable"."created_at", @@ -7518,7 +8192,152 @@ AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) ''' # --- -# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.95 +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.87 + ''' + SELECT "posthog_datawarehousejoin"."created_by_id", + "posthog_datawarehousejoin"."created_at", + "posthog_datawarehousejoin"."deleted", + "posthog_datawarehousejoin"."deleted_at", + "posthog_datawarehousejoin"."id", + "posthog_datawarehousejoin"."team_id", + "posthog_datawarehousejoin"."source_table_name", + "posthog_datawarehousejoin"."source_table_key", + "posthog_datawarehousejoin"."joining_table_name", + "posthog_datawarehousejoin"."joining_table_key", + "posthog_datawarehousejoin"."field_name" + FROM "posthog_datawarehousejoin" + WHERE ("posthog_datawarehousejoin"."team_id" = 99999 + AND NOT ("posthog_datawarehousejoin"."deleted" + AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.88 + ''' + SELECT "posthog_grouptypemapping"."id", + "posthog_grouptypemapping"."team_id", + "posthog_grouptypemapping"."project_id", + "posthog_grouptypemapping"."group_type", + "posthog_grouptypemapping"."group_type_index", + "posthog_grouptypemapping"."name_singular", + "posthog_grouptypemapping"."name_plural" + FROM "posthog_grouptypemapping" + WHERE "posthog_grouptypemapping"."team_id" = 99999 + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.89 + ''' + SELECT "posthog_datawarehousesavedquery"."created_by_id", + "posthog_datawarehousesavedquery"."created_at", + "posthog_datawarehousesavedquery"."deleted", + "posthog_datawarehousesavedquery"."deleted_at", + "posthog_datawarehousesavedquery"."id", + "posthog_datawarehousesavedquery"."name", + "posthog_datawarehousesavedquery"."team_id", + "posthog_datawarehousesavedquery"."columns", + "posthog_datawarehousesavedquery"."external_tables", + "posthog_datawarehousesavedquery"."query", + "posthog_datawarehousesavedquery"."status", + "posthog_datawarehousesavedquery"."last_run_at", + "posthog_datawarehousesavedquery"."table_id" + FROM "posthog_datawarehousesavedquery" + WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 + AND NOT ("posthog_datawarehousesavedquery"."deleted" + AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.9 + ''' + SELECT "posthog_datawarehousejoin"."created_by_id", + "posthog_datawarehousejoin"."created_at", + "posthog_datawarehousejoin"."deleted", + "posthog_datawarehousejoin"."deleted_at", + "posthog_datawarehousejoin"."id", + "posthog_datawarehousejoin"."team_id", + "posthog_datawarehousejoin"."source_table_name", + "posthog_datawarehousejoin"."source_table_key", + "posthog_datawarehousejoin"."joining_table_name", + "posthog_datawarehousejoin"."joining_table_key", + "posthog_datawarehousejoin"."field_name" + FROM "posthog_datawarehousejoin" + WHERE ("posthog_datawarehousejoin"."team_id" = 99999 + AND NOT ("posthog_datawarehousejoin"."deleted" + AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.90 + ''' + SELECT "posthog_datawarehousetable"."created_by_id", + "posthog_datawarehousetable"."created_at", + "posthog_datawarehousetable"."updated_at", + "posthog_datawarehousetable"."deleted", + "posthog_datawarehousetable"."deleted_at", + "posthog_datawarehousetable"."id", + "posthog_datawarehousetable"."name", + "posthog_datawarehousetable"."format", + "posthog_datawarehousetable"."team_id", + "posthog_datawarehousetable"."url_pattern", + "posthog_datawarehousetable"."credential_id", + "posthog_datawarehousetable"."external_data_source_id", + "posthog_datawarehousetable"."columns", + "posthog_datawarehousetable"."row_count", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in", + "posthog_datawarehousecredential"."created_by_id", + "posthog_datawarehousecredential"."created_at", + "posthog_datawarehousecredential"."id", + "posthog_datawarehousecredential"."access_key", + "posthog_datawarehousecredential"."access_secret", + "posthog_datawarehousecredential"."team_id", + "posthog_externaldatasource"."created_by_id", + "posthog_externaldatasource"."created_at", + "posthog_externaldatasource"."updated_at", + "posthog_externaldatasource"."deleted", + "posthog_externaldatasource"."deleted_at", + "posthog_externaldatasource"."id", + "posthog_externaldatasource"."source_id", + "posthog_externaldatasource"."connection_id", + "posthog_externaldatasource"."destination_id", + "posthog_externaldatasource"."team_id", + "posthog_externaldatasource"."sync_frequency", + "posthog_externaldatasource"."status", + "posthog_externaldatasource"."source_type", + "posthog_externaldatasource"."job_inputs", + "posthog_externaldatasource"."are_tables_created", + "posthog_externaldatasource"."prefix" + FROM "posthog_datawarehousetable" + LEFT OUTER JOIN "posthog_user" ON ("posthog_datawarehousetable"."created_by_id" = "posthog_user"."id") + LEFT OUTER JOIN "posthog_datawarehousecredential" ON ("posthog_datawarehousetable"."credential_id" = "posthog_datawarehousecredential"."id") + LEFT OUTER JOIN "posthog_externaldatasource" ON ("posthog_datawarehousetable"."external_data_source_id" = "posthog_externaldatasource"."id") + WHERE ("posthog_datawarehousetable"."team_id" = 99999 + AND NOT ("posthog_datawarehousetable"."deleted" + AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.91 ''' SELECT "posthog_datawarehousejoin"."created_by_id", "posthog_datawarehousejoin"."created_at", @@ -7537,57 +8356,181 @@ AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) ''' # --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.92 + ''' + SELECT "posthog_sessionrecording"."id", + "posthog_sessionrecording"."session_id", + "posthog_sessionrecording"."team_id", + "posthog_sessionrecording"."created_at", + "posthog_sessionrecording"."deleted", + "posthog_sessionrecording"."object_storage_path", + "posthog_sessionrecording"."distinct_id", + "posthog_sessionrecording"."duration", + "posthog_sessionrecording"."active_seconds", + "posthog_sessionrecording"."inactive_seconds", + "posthog_sessionrecording"."start_time", + "posthog_sessionrecording"."end_time", + "posthog_sessionrecording"."click_count", + "posthog_sessionrecording"."keypress_count", + "posthog_sessionrecording"."mouse_activity_count", + "posthog_sessionrecording"."console_log_count", + "posthog_sessionrecording"."console_warn_count", + "posthog_sessionrecording"."console_error_count", + "posthog_sessionrecording"."start_url", + "posthog_sessionrecording"."storage_version" + FROM "posthog_sessionrecording" + WHERE ("posthog_sessionrecording"."session_id" IN ('1', + '2', + '3', + '4') + AND "posthog_sessionrecording"."team_id" = 99999) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.93 + ''' + SELECT "posthog_sessionrecordingviewed"."session_id" + FROM "posthog_sessionrecordingviewed" + WHERE ("posthog_sessionrecordingviewed"."team_id" = 99999 + AND "posthog_sessionrecordingviewed"."user_id" = 99999) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.94 + ''' + SELECT "posthog_persondistinctid"."id", + "posthog_persondistinctid"."team_id", + "posthog_persondistinctid"."person_id", + "posthog_persondistinctid"."distinct_id", + "posthog_persondistinctid"."version", + "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_persondistinctid" + INNER JOIN "posthog_person" ON ("posthog_persondistinctid"."person_id" = "posthog_person"."id") + WHERE ("posthog_persondistinctid"."distinct_id" IN ('user1', + 'user2', + 'user3', + 'user4') + AND "posthog_persondistinctid"."team_id" = 99999) + ''' +# --- +# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.95 + ''' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."plugins_opt_in", + "posthog_team"."opt_out_capture", + "posthog_team"."event_names", + "posthog_team"."event_names_with_usage", + "posthog_team"."event_properties", + "posthog_team"."event_properties_with_usage", + "posthog_team"."event_properties_numerical", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 + ''' +# --- # name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.96 ''' - SELECT "posthog_grouptypemapping"."id", - "posthog_grouptypemapping"."team_id", - "posthog_grouptypemapping"."project_id", - "posthog_grouptypemapping"."group_type", - "posthog_grouptypemapping"."group_type_index", - "posthog_grouptypemapping"."name_singular", - "posthog_grouptypemapping"."name_plural" - FROM "posthog_grouptypemapping" - WHERE "posthog_grouptypemapping"."team_id" = 99999 + SELECT "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_person" + INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") + WHERE ("posthog_persondistinctid"."distinct_id" = 'user5' + AND "posthog_persondistinctid"."team_id" = 99999) + LIMIT 21 ''' # --- # name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.97 ''' - SELECT "posthog_datawarehousesavedquery"."created_by_id", - "posthog_datawarehousesavedquery"."created_at", - "posthog_datawarehousesavedquery"."deleted", - "posthog_datawarehousesavedquery"."deleted_at", - "posthog_datawarehousesavedquery"."id", - "posthog_datawarehousesavedquery"."name", - "posthog_datawarehousesavedquery"."team_id", - "posthog_datawarehousesavedquery"."columns", - "posthog_datawarehousesavedquery"."external_tables", - "posthog_datawarehousesavedquery"."query", - "posthog_datawarehousesavedquery"."status", - "posthog_datawarehousesavedquery"."last_run_at", - "posthog_datawarehousesavedquery"."table_id" - FROM "posthog_datawarehousesavedquery" - WHERE ("posthog_datawarehousesavedquery"."team_id" = 99999 - AND NOT ("posthog_datawarehousesavedquery"."deleted" - AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL)) + SELECT "posthog_person"."id", + "posthog_person"."created_at", + "posthog_person"."properties_last_updated_at", + "posthog_person"."properties_last_operation", + "posthog_person"."team_id", + "posthog_person"."properties", + "posthog_person"."is_user_id", + "posthog_person"."is_identified", + "posthog_person"."uuid", + "posthog_person"."version" + FROM "posthog_person" + INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") + WHERE ("posthog_persondistinctid"."distinct_id" = 'user5' + AND "posthog_persondistinctid"."team_id" = 99999) + LIMIT 21 ''' # --- # name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.98 ''' - SELECT "posthog_datawarehousetable"."created_by_id", - "posthog_datawarehousetable"."created_at", - "posthog_datawarehousetable"."updated_at", - "posthog_datawarehousetable"."deleted", - "posthog_datawarehousetable"."deleted_at", - "posthog_datawarehousetable"."id", - "posthog_datawarehousetable"."name", - "posthog_datawarehousetable"."format", - "posthog_datawarehousetable"."team_id", - "posthog_datawarehousetable"."url_pattern", - "posthog_datawarehousetable"."credential_id", - "posthog_datawarehousetable"."external_data_source_id", - "posthog_datawarehousetable"."columns", - "posthog_datawarehousetable"."row_count", - "posthog_user"."id", + SELECT "posthog_user"."id", "posthog_user"."password", "posthog_user"."last_login", "posthog_user"."first_name", @@ -7602,7 +8545,6 @@ "posthog_user"."temporary_token", "posthog_user"."distinct_id", "posthog_user"."is_email_verified", - "posthog_user"."requested_password_reset_at", "posthog_user"."has_seen_product_intro_for", "posthog_user"."strapi_id", "posthog_user"."is_active", @@ -7612,54 +8554,72 @@ "posthog_user"."toolbar_mode", "posthog_user"."hedgehog_config", "posthog_user"."events_column_config", - "posthog_user"."email_opt_in", - "posthog_datawarehousecredential"."created_by_id", - "posthog_datawarehousecredential"."created_at", - "posthog_datawarehousecredential"."id", - "posthog_datawarehousecredential"."access_key", - "posthog_datawarehousecredential"."access_secret", - "posthog_datawarehousecredential"."team_id", - "posthog_externaldatasource"."created_by_id", - "posthog_externaldatasource"."created_at", - "posthog_externaldatasource"."updated_at", - "posthog_externaldatasource"."deleted", - "posthog_externaldatasource"."deleted_at", - "posthog_externaldatasource"."id", - "posthog_externaldatasource"."source_id", - "posthog_externaldatasource"."connection_id", - "posthog_externaldatasource"."destination_id", - "posthog_externaldatasource"."team_id", - "posthog_externaldatasource"."sync_frequency", - "posthog_externaldatasource"."status", - "posthog_externaldatasource"."source_type", - "posthog_externaldatasource"."job_inputs", - "posthog_externaldatasource"."are_tables_created", - "posthog_externaldatasource"."prefix" - FROM "posthog_datawarehousetable" - LEFT OUTER JOIN "posthog_user" ON ("posthog_datawarehousetable"."created_by_id" = "posthog_user"."id") - LEFT OUTER JOIN "posthog_datawarehousecredential" ON ("posthog_datawarehousetable"."credential_id" = "posthog_datawarehousecredential"."id") - LEFT OUTER JOIN "posthog_externaldatasource" ON ("posthog_datawarehousetable"."external_data_source_id" = "posthog_externaldatasource"."id") - WHERE ("posthog_datawarehousetable"."team_id" = 99999 - AND NOT ("posthog_datawarehousetable"."deleted" - AND "posthog_datawarehousetable"."deleted" IS NOT NULL)) + "posthog_user"."email_opt_in" + FROM "posthog_user" + WHERE "posthog_user"."id" = 99999 + LIMIT 21 ''' # --- # name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons.99 ''' - SELECT "posthog_datawarehousejoin"."created_by_id", - "posthog_datawarehousejoin"."created_at", - "posthog_datawarehousejoin"."deleted", - "posthog_datawarehousejoin"."deleted_at", - "posthog_datawarehousejoin"."id", - "posthog_datawarehousejoin"."team_id", - "posthog_datawarehousejoin"."source_table_name", - "posthog_datawarehousejoin"."source_table_key", - "posthog_datawarehousejoin"."joining_table_name", - "posthog_datawarehousejoin"."joining_table_key", - "posthog_datawarehousejoin"."field_name" - FROM "posthog_datawarehousejoin" - WHERE ("posthog_datawarehousejoin"."team_id" = 99999 - AND NOT ("posthog_datawarehousejoin"."deleted" - AND "posthog_datawarehousejoin"."deleted" IS NOT NULL)) + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_id", + "posthog_team"."project_id", + "posthog_team"."api_token", + "posthog_team"."app_urls", + "posthog_team"."name", + "posthog_team"."slack_incoming_webhook", + "posthog_team"."created_at", + "posthog_team"."updated_at", + "posthog_team"."anonymize_ips", + "posthog_team"."completed_snippet_onboarding", + "posthog_team"."has_completed_onboarding_for", + "posthog_team"."ingested_event", + "posthog_team"."autocapture_opt_out", + "posthog_team"."autocapture_web_vitals_opt_in", + "posthog_team"."autocapture_web_vitals_allowed_metrics", + "posthog_team"."autocapture_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "posthog_team"."person_processing_opt_out", + "posthog_team"."session_recording_opt_in", + "posthog_team"."session_recording_sample_rate", + "posthog_team"."session_recording_minimum_duration_milliseconds", + "posthog_team"."session_recording_linked_flag", + "posthog_team"."session_recording_network_payload_capture_config", + "posthog_team"."session_recording_url_trigger_config", + "posthog_team"."session_recording_url_blocklist_config", + "posthog_team"."session_recording_event_trigger_config", + "posthog_team"."session_replay_config", + "posthog_team"."survey_config", + "posthog_team"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."capture_dead_clicks", + "posthog_team"."surveys_opt_in", + "posthog_team"."heatmaps_opt_in", + "posthog_team"."session_recording_version", + "posthog_team"."signup_token", + "posthog_team"."is_demo", + "posthog_team"."access_control", + "posthog_team"."week_start_day", + "posthog_team"."inject_web_apps", + "posthog_team"."test_account_filters", + "posthog_team"."test_account_filters_default_checked", + "posthog_team"."path_cleaning_filters", + "posthog_team"."timezone", + "posthog_team"."data_attributes", + "posthog_team"."person_display_name_properties", + "posthog_team"."live_events_columns", + "posthog_team"."recording_domains", + "posthog_team"."primary_dashboard_id", + "posthog_team"."extra_settings", + "posthog_team"."modifiers", + "posthog_team"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id", + "posthog_team"."external_data_workspace_last_synced_at" + FROM "posthog_team" + WHERE "posthog_team"."id" = 99999 + LIMIT 21 ''' # --- diff --git a/posthog/test/test_middleware.py b/posthog/test/test_middleware.py index 2788ad6503c20..e6a9e95ac9ba0 100644 --- a/posthog/test/test_middleware.py +++ b/posthog/test/test_middleware.py @@ -164,7 +164,7 @@ def setUp(self): def test_project_switched_when_accessing_dashboard_of_another_accessible_team(self): dashboard = Dashboard.objects.create(team=self.second_team) - with self.assertNumQueries(self.base_app_num_queries + 4): # AutoProjectMiddleware adds 4 queries + with self.assertNumQueries(self.base_app_num_queries + 7): # AutoProjectMiddleware adds 4 queries response_app = self.client.get(f"/dashboard/{dashboard.id}") response_users_api = self.client.get(f"/api/users/@me/") response_users_api_data = response_users_api.json() @@ -212,7 +212,7 @@ def test_project_unchanged_when_accessing_dashboard_of_another_off_limits_team(s @override_settings(PERSON_ON_EVENTS_V2_OVERRIDE=False) def test_project_unchanged_when_accessing_dashboards_list(self): - with self.assertNumQueries(self.base_app_num_queries): # No AutoProjectMiddleware queries + with self.assertNumQueries(self.base_app_num_queries + 2): # No AutoProjectMiddleware queries response_app = self.client.get(f"/dashboard") response_users_api = self.client.get(f"/api/users/@me/") response_users_api_data = response_users_api.json() @@ -282,7 +282,7 @@ def test_project_switched_when_accessing_cohort_of_another_accessible_team(self) def test_project_switched_when_accessing_feature_flag_of_another_accessible_team(self): feature_flag = FeatureFlag.objects.create(team=self.second_team, created_by=self.user) - with self.assertNumQueries(self.base_app_num_queries + 4): + with self.assertNumQueries(self.base_app_num_queries + 7): response_app = self.client.get(f"/feature_flags/{feature_flag.id}") response_users_api = self.client.get(f"/api/users/@me/") response_users_api_data = response_users_api.json() @@ -296,7 +296,7 @@ def test_project_switched_when_accessing_feature_flag_of_another_accessible_team @override_settings(PERSON_ON_EVENTS_V2_OVERRIDE=False) def test_project_unchanged_when_creating_feature_flag(self): - with self.assertNumQueries(self.base_app_num_queries): + with self.assertNumQueries(self.base_app_num_queries + 2): response_app = self.client.get(f"/feature_flags/new") response_users_api = self.client.get(f"/api/users/@me/") response_users_api_data = response_users_api.json() diff --git a/posthog/utils.py b/posthog/utils.py index 7535df0700638..d8ea9315fec7c 100644 --- a/posthog/utils.py +++ b/posthog/utils.py @@ -368,6 +368,7 @@ def render_template( from posthog.api.project import ProjectSerializer from posthog.api.user import UserSerializer from posthog.user_permissions import UserPermissions + from posthog.rbac.user_access_control import UserAccessControl from posthog.views import preflight_check posthog_app_context = { @@ -390,9 +391,14 @@ def render_template( elif request.user.pk: user = cast("User", request.user) user_permissions = UserPermissions(user=user, team=user.team) + user_access_control = UserAccessControl(user=user, team=user.team) user_serialized = UserSerializer( request.user, - context={"request": request, "user_permissions": user_permissions}, + context={ + "request": request, + "user_permissions": user_permissions, + "user_access_control": user_access_control, + }, many=False, ) posthog_app_context["current_user"] = user_serialized.data @@ -400,7 +406,11 @@ def render_template( if user.team: team_serialized = TeamSerializer( user.team, - context={"request": request, "user_permissions": user_permissions}, + context={ + "request": request, + "user_permissions": user_permissions, + "user_access_control": user_access_control, + }, many=False, ) posthog_app_context["current_team"] = team_serialized.data diff --git a/posthog/warehouse/api/test/test_external_data_source.py b/posthog/warehouse/api/test/test_external_data_source.py index b191f10e04785..f638700822af8 100644 --- a/posthog/warehouse/api/test/test_external_data_source.py +++ b/posthog/warehouse/api/test/test_external_data_source.py @@ -374,7 +374,7 @@ def test_list_external_data_source(self): self._create_external_data_source() self._create_external_data_source() - with self.assertNumQueries(17): + with self.assertNumQueries(19): response = self.client.get(f"/api/projects/{self.team.pk}/external_data_sources/") payload = response.json() From 1a92ad3700b316c1df598eb8ef7b0e7bfa7ccea6 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 23:28:50 +0000 Subject: [PATCH 2/9] Update query snapshots --- .../test_session_recordings.ambr | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr index 55770386bd565..9a99f93b00619 100644 --- a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr +++ b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr @@ -640,12 +640,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '413' + AND "ee_accesscontrol"."resource_id" = '462' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '413' + AND "ee_accesscontrol"."resource_id" = '462' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -1688,12 +1688,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -2441,12 +2441,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -3129,12 +3129,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -3881,12 +3881,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -4597,12 +4597,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -5395,12 +5395,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -5659,12 +5659,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -6091,12 +6091,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -6556,12 +6556,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -7248,12 +7248,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -7997,12 +7997,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '420' + AND "ee_accesscontrol"."resource_id" = '469' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL From 09cdaa42fa279dd85bb658a467ca1f8cdead45e2 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 00:07:29 +0000 Subject: [PATCH 3/9] Update query snapshots --- posthog/api/test/__snapshots__/test_feature_flag.ambr | 4 ++-- posthog/api/test/__snapshots__/test_insight.ambr | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/posthog/api/test/__snapshots__/test_feature_flag.ambr b/posthog/api/test/__snapshots__/test_feature_flag.ambr index 9662d335f039e..93dfa76ea2cdb 100644 --- a/posthog/api/test/__snapshots__/test_feature_flag.ambr +++ b/posthog/api/test/__snapshots__/test_feature_flag.ambr @@ -2001,12 +2001,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '310' + AND "ee_accesscontrol"."resource_id" = '313' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '310' + AND "ee_accesscontrol"."resource_id" = '313' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL diff --git a/posthog/api/test/__snapshots__/test_insight.ambr b/posthog/api/test/__snapshots__/test_insight.ambr index 2e95c4f809659..70e4ceac486c9 100644 --- a/posthog/api/test/__snapshots__/test_insight.ambr +++ b/posthog/api/test/__snapshots__/test_insight.ambr @@ -1380,12 +1380,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '438' + AND "ee_accesscontrol"."resource_id" = '441' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '438' + AND "ee_accesscontrol"."resource_id" = '441' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -1493,12 +1493,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '438' + AND "ee_accesscontrol"."resource_id" = '441' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '438' + AND "ee_accesscontrol"."resource_id" = '441' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL From 13e68444db44591d849fe90f7a9257ec795917a4 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 00:09:21 +0000 Subject: [PATCH 4/9] Update query snapshots --- .../test_session_recordings.ambr | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr index 9a99f93b00619..940180af4e224 100644 --- a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr +++ b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr @@ -640,12 +640,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '462' + AND "ee_accesscontrol"."resource_id" = '456' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '462' + AND "ee_accesscontrol"."resource_id" = '456' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -1688,12 +1688,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -2441,12 +2441,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -3129,12 +3129,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -3881,12 +3881,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -4597,12 +4597,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -5395,12 +5395,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -5659,12 +5659,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -6091,12 +6091,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -6556,12 +6556,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -7248,12 +7248,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -7997,12 +7997,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '469' + AND "ee_accesscontrol"."resource_id" = '463' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL From c5c6cf5a06cde43a30a556b6810b35c1104d9f7b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:18:14 +0000 Subject: [PATCH 5/9] Update query snapshots --- .../test_session_recordings.ambr | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr index 940180af4e224..ca06cf910d628 100644 --- a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr +++ b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr @@ -640,12 +640,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '456' + AND "ee_accesscontrol"."resource_id" = '447' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '456' + AND "ee_accesscontrol"."resource_id" = '447' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -1688,12 +1688,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -2441,12 +2441,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -3129,12 +3129,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -3881,12 +3881,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -4597,12 +4597,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -5395,12 +5395,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -5659,12 +5659,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -6091,12 +6091,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -6556,12 +6556,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -7248,12 +7248,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL @@ -7997,12 +7997,12 @@ LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") WHERE (("ee_accesscontrol"."organization_member_id" IS NULL AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("posthog_organizationmembership"."user_id" = 99999 AND "ee_accesscontrol"."resource" = 'project' - AND "ee_accesscontrol"."resource_id" = '463' + AND "ee_accesscontrol"."resource_id" = '454' AND "ee_accesscontrol"."role_id" IS NULL AND "ee_accesscontrol"."team_id" = 99999) OR ("ee_accesscontrol"."organization_member_id" IS NULL From f1ac5bcec1f24e5208d9b3e429bb0f4845ac8d86 Mon Sep 17 00:00:00 2001 From: Zach Waterfield Date: Tue, 26 Nov 2024 20:28:29 -0500 Subject: [PATCH 6/9] add current team check in permission class --- posthog/permissions.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/posthog/permissions.py b/posthog/permissions.py index 4f49616cd5875..4e9614a50c2a4 100644 --- a/posthog/permissions.py +++ b/posthog/permissions.py @@ -22,6 +22,7 @@ from posthog.models.scopes import APIScopeObject, APIScopeObjectOrNotSupported from posthog.rbac.user_access_control import AccessControlLevel, UserAccessControl, ordered_access_levels from posthog.utils import get_can_create_org +from rest_framework.exceptions import AuthenticationFailed CREATE_ACTIONS = ["create", "update"] @@ -483,6 +484,12 @@ def has_permission(self, request, view) -> bool: # Primarily we are checking the user's access to the parent resource type (i.e. project, organization) # as well as enforcing any global restrictions (e.g. generically only editing of a flag is allowed) + # Check if the endpoint requires a current team to be set on the user + if hasattr(view, "param_derived_from_user_current_team"): + if view.param_derived_from_user_current_team in ("team_id", "project_id"): + if request.user.current_team_id is None: + raise AuthenticationFailed("This endpoint requires a current project to be set on your account.") + uac = self._get_user_access_control(request, view) scope_object = self._get_scope_object(request, view) required_level = self._get_required_access_level(request, view) From 039235c76ed55b89112757a9a66db71b054f034b Mon Sep 17 00:00:00 2001 From: Zach Waterfield Date: Wed, 27 Nov 2024 09:19:34 -0500 Subject: [PATCH 7/9] fix tests --- posthog/api/search.py | 2 +- posthog/api/test/test_decide.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/posthog/api/search.py b/posthog/api/search.py index 4d35b8db44edf..6bdf619009066 100644 --- a/posthog/api/search.py +++ b/posthog/api/search.py @@ -110,7 +110,7 @@ def list(self, request: Request, **kw) -> HttpResponse: assert entity_meta is not None klass_qs, entity_name = class_queryset( view=self, - klass=entity_meta.get("klass"), + klass=entity_meta["klass"], project_id=self.project_id, query=query, search_fields=entity_meta["search_fields"], diff --git a/posthog/api/test/test_decide.py b/posthog/api/test/test_decide.py index 63505d8f7048f..69046227deab0 100644 --- a/posthog/api/test/test_decide.py +++ b/posthog/api/test/test_decide.py @@ -4699,7 +4699,7 @@ def test_local_evaluation(self, mock_rate_limit, mock_capture): response = self.client.get(f"/api/feature_flag/local_evaluation") self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) - with self.assertNumQueries(3, using="replica"), self.assertNumQueries(12, using="default"): + with self.assertNumQueries(3, using="replica"), self.assertNumQueries(9, using="default"): # Captured queries for write DB: # E 1. UPDATE "posthog_personalapikey" SET "last_used_at" = '2023-08-01T11:26:50.728057+00:00' # E 2. SELECT "posthog_team"."id", "posthog_team"."uuid", "posthog_team"."organization_id" @@ -4940,7 +4940,7 @@ def test_local_evaluation_for_cohorts(self, mock_rate_limit, mock_capture): PersonalAPIKey.objects.create(label="X", user=self.user, secure_value=hash_key_value(personal_api_key)) cache.clear() - with self.assertNumQueries(4, using="replica"), self.assertNumQueries(12, using="default"): + with self.assertNumQueries(4, using="replica"), self.assertNumQueries(9, using="default"): # Captured queries for write DB: # E 1. UPDATE "posthog_personalapikey" SET "last_used_at" = '2023-08-01T11:26:50.728057+00:00' # E 2. SELECT "posthog_team"."id", "posthog_team"."uuid", "posthog_team"."organization_id" @@ -5210,7 +5210,7 @@ def test_local_evaluation_for_arbitrary_cohorts(self, mock_rate_limit, mock_capt client.logout() self.client.logout() - with self.assertNumQueries(4, using="replica"), self.assertNumQueries(12, using="default"): + with self.assertNumQueries(4, using="replica"), self.assertNumQueries(9, using="default"): # Captured queries for write DB: # E 1. UPDATE "posthog_personalapikey" SET "last_used_at" = '2023-08-01T11:26:50.728057+00:00' # E 2. SELECT "posthog_team"."id", "posthog_team"."uuid", "posthog_team"."organization_id" From 94f946710e167955f83660e0025b77d3ede5a17b Mon Sep 17 00:00:00 2001 From: Zach Waterfield Date: Wed, 27 Nov 2024 09:35:40 -0500 Subject: [PATCH 8/9] add current team and org --- posthog/api/test/test_decide.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/posthog/api/test/test_decide.py b/posthog/api/test/test_decide.py index 69046227deab0..aa9862dcb146d 100644 --- a/posthog/api/test/test_decide.py +++ b/posthog/api/test/test_decide.py @@ -3784,6 +3784,8 @@ def setup_user_and_team_in_db(self, dbname: str = "default"): email=f"test-{random.randint(1, 100000)}@posthog.com", password="password", first_name="first_name", + current_team=team, + current_organization=organization, ) OrganizationMembership.objects.db_manager(dbname).create( user=user, From e55fe52c2026ff68aadbf5f960793fadf4e71e77 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:59:16 +0000 Subject: [PATCH 9/9] Update query snapshots --- .../api/test/__snapshots__/test_element.ambr | 78 ++++++++ .../api/test/__snapshots__/test_insight.ambr | 2 +- .../__snapshots__/test_notebook.ambr | 169 +++++++++++++++++- 3 files changed, 247 insertions(+), 2 deletions(-) diff --git a/posthog/api/test/__snapshots__/test_element.ambr b/posthog/api/test/__snapshots__/test_element.ambr index 6b3f676ad2211..414a8a1831062 100644 --- a/posthog/api/test/__snapshots__/test_element.ambr +++ b/posthog/api/test/__snapshots__/test_element.ambr @@ -135,3 +135,81 @@ LIMIT 21 ''' # --- +# name: TestElement.test_element_stats_postgres_queries_are_as_expected.3 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '272' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '272' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'INTERNAL' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'INTERNAL' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'INTERNAL' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'INTERNAL' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestElement.test_element_stats_postgres_queries_are_as_expected.4 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- diff --git a/posthog/api/test/__snapshots__/test_insight.ambr b/posthog/api/test/__snapshots__/test_insight.ambr index 1d2b0d98bf2fb..b6d0b7945dd2d 100644 --- a/posthog/api/test/__snapshots__/test_insight.ambr +++ b/posthog/api/test/__snapshots__/test_insight.ambr @@ -1993,7 +1993,7 @@ LIMIT 21 ''' # --- -# name: TestInsight.test_listing_insights_does_not_nplus1.4 +# name: TestInsight.test_listing_insights_does_not_nplus1.6 ''' SELECT "posthog_team"."id", "posthog_team"."uuid", diff --git a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr index 1c7931ceede0d..6527545701a76 100644 --- a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr +++ b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr @@ -582,7 +582,174 @@ AND "ee_accesscontrol"."team_id" = 99999)) ''' # --- -# name: TestNotebooks.test_updates_notebook.2 +# name: TestNotebooks.test_updates_notebook.21 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE "posthog_organizationmembership"."user_id" = 99999 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.22 + ''' + SELECT COUNT(*) AS "__count" + FROM "posthog_activitylog" + WHERE ("posthog_activitylog"."scope" = 'Notebook' + AND "posthog_activitylog"."team_id" = 99999) + ''' +# --- +# name: TestNotebooks.test_updates_notebook.23 + ''' + SELECT "posthog_activitylog"."id", + "posthog_activitylog"."team_id", + "posthog_activitylog"."organization_id", + "posthog_activitylog"."user_id", + "posthog_activitylog"."was_impersonated", + "posthog_activitylog"."is_system", + "posthog_activitylog"."activity", + "posthog_activitylog"."item_id", + "posthog_activitylog"."scope", + "posthog_activitylog"."detail", + "posthog_activitylog"."created_at", + "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."requested_password_reset_at", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."strapi_id", + "posthog_user"."is_active", + "posthog_user"."theme_mode", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."hedgehog_config", + "posthog_user"."events_column_config", + "posthog_user"."email_opt_in" + FROM "posthog_activitylog" + LEFT OUTER JOIN "posthog_user" ON ("posthog_activitylog"."user_id" = "posthog_user"."id") + WHERE ("posthog_activitylog"."scope" = 'Notebook' + AND "posthog_activitylog"."team_id" = 99999) + ORDER BY "posthog_activitylog"."created_at" DESC + LIMIT 2 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.3 + ''' + SELECT "posthog_organizationmembership"."id", + "posthog_organizationmembership"."organization_id", + "posthog_organizationmembership"."user_id", + "posthog_organizationmembership"."level", + "posthog_organizationmembership"."joined_at", + "posthog_organizationmembership"."updated_at", + "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "posthog_organization"."logo_media_id", + "posthog_organization"."created_at", + "posthog_organization"."updated_at", + "posthog_organization"."plugins_access_level", + "posthog_organization"."for_internal_metrics", + "posthog_organization"."is_member_join_email_enabled", + "posthog_organization"."enforce_2fa", + "posthog_organization"."is_hipaa", + "posthog_organization"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."customer_trust_scores", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist" + FROM "posthog_organizationmembership" + INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id") + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 99999) + LIMIT 21 + ''' +# --- +# name: TestNotebooks.test_updates_notebook.4 + ''' + SELECT "ee_accesscontrol"."id", + "ee_accesscontrol"."team_id", + "ee_accesscontrol"."access_level", + "ee_accesscontrol"."resource", + "ee_accesscontrol"."resource_id", + "ee_accesscontrol"."organization_member_id", + "ee_accesscontrol"."role_id", + "ee_accesscontrol"."created_by_id", + "ee_accesscontrol"."created_at", + "ee_accesscontrol"."updated_at" + FROM "ee_accesscontrol" + LEFT OUTER JOIN "posthog_organizationmembership" ON ("ee_accesscontrol"."organization_member_id" = "posthog_organizationmembership"."id") + WHERE (("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '83' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'project' + AND "ee_accesscontrol"."resource_id" = '83' + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("ee_accesscontrol"."organization_member_id" IS NULL + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999) + OR ("posthog_organizationmembership"."user_id" = 99999 + AND "ee_accesscontrol"."resource" = 'notebook' + AND "ee_accesscontrol"."resource_id" IS NOT NULL + AND "ee_accesscontrol"."role_id" IS NULL + AND "ee_accesscontrol"."team_id" = 99999)) + ''' +# --- +# name: TestNotebooks.test_updates_notebook.5 ''' SELECT "posthog_organizationmembership"."id", "posthog_organizationmembership"."organization_id",