Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"""add indexes

Revision ID: aa2c85e8a66a
Revises: 48604dfdc5f4
Create Date: 2025-04-03 15:45:02.586547+00:00

"""

from alembic import op

# revision identifiers, used by Alembic.
revision = "aa2c85e8a66a"
down_revision = "48604dfdc5f4"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(
"idx_project_to_groups_gid", "project_to_groups", ["gid"], unique=False
)
op.create_index(
"idx_projects_last_change_date_desc",
"projects",
["last_change_date"],
unique=False,
postgresql_using="btree",
postgresql_ops={"last_change_date": "DESC"},
)
op.create_index("idx_projects_type", "projects", ["type"], unique=False)
op.create_index(
"idx_project_to_folders_project_uuid",
"projects_to_folders",
["project_uuid"],
unique=False,
)
op.create_index(
"idx_project_to_folders_user_id",
"projects_to_folders",
["user_id"],
unique=False,
)
op.create_index(
"idx_projects_to_products_product_name",
"projects_to_products",
["product_name"],
unique=False,
)
op.create_index(
"idx_workspaces_access_rights_gid",
"workspaces_access_rights",
["gid"],
unique=False,
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(
"idx_workspaces_access_rights_gid", table_name="workspaces_access_rights"
)
op.drop_index(
"idx_projects_to_products_product_name", table_name="projects_to_products"
)
op.drop_index("idx_project_to_folders_user_id", table_name="projects_to_folders")
op.drop_index(
"idx_project_to_folders_project_uuid", table_name="projects_to_folders"
)
op.drop_index("idx_projects_type", table_name="projects")
op.drop_index(
"idx_projects_last_change_date_desc",
table_name="projects",
postgresql_using="btree",
postgresql_ops={"last_change_date": "DESC"},
)
op.drop_index("idx_project_to_groups_gid", table_name="project_to_groups")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@
column_created_datetime(timezone=True),
column_modified_datetime(timezone=True),
sa.UniqueConstraint("project_uuid", "gid"),
sa.Index("idx_project_to_groups_gid", "gid"),
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
""" Projects table
"""Projects table"""

"""
import enum

import sqlalchemy as sa
Expand Down Expand Up @@ -171,6 +170,14 @@ class ProjectType(enum.Enum):
server_default=sa.text("'{}'::jsonb"),
doc="DEPRECATED: Read/write/delete access rights of each group (gid) on this project",
),
### INDEXES ----------------------------
sa.Index("idx_projects_type", "type"),
sa.Index(
"idx_projects_last_change_date_desc",
"last_change_date",
postgresql_using="btree",
postgresql_ops={"last_change_date": "DESC"},
),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@
column_created_datetime(timezone=True),
column_modified_datetime(timezone=True),
sa.UniqueConstraint("project_uuid", "folder_id", "user_id"),
sa.Index("idx_project_to_folders_project_uuid", "project_uuid"),
sa.Index("idx_project_to_folders_user_id", "user_id"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
column_created_datetime(timezone=False),
column_modified_datetime(timezone=False),
sa.UniqueConstraint("project_uuid", "product_name"),
sa.Index("idx_projects_to_products_product_name", "product_name"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@
column_created_datetime(timezone=True),
column_modified_datetime(timezone=True),
sa.UniqueConstraint("workspace_id", "gid"),
sa.Index("idx_workspaces_access_rights_gid", "gid"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,11 @@ async def list_projects_full_search(request: web.Request):
if not query_params.filters:
query_params.filters = ProjectFilters()

tag_ids_list = query_params.tag_ids_list()

projects, total_number_of_projects = await _crud_api_read.list_projects_full_depth(
request.app,
user_id=req_ctx.user_id,
product_name=req_ctx.product_name,
trashed=query_params.filters.trashed,
tag_ids_list=tag_ids_list,
search_by_multi_columns=query_params.text,
search_by_project_name=query_params.filters.search_by_project_name,
offset=query_params.offset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ async def list_projects_full_depth(
product_name: str,
# attrs filter
trashed: bool | None,
tag_ids_list: list[int],
# pagination
offset: NonNegativeInt,
limit: int,
Expand All @@ -199,7 +198,6 @@ async def list_projects_full_depth(
folder_query=FolderQuery(folder_scope=FolderScope.ALL),
filter_trashed=trashed,
filter_by_services=user_available_services,
filter_tag_ids_list=tag_ids_list,
filter_by_project_type=ProjectType.STANDARD,
search_by_multi_columns=search_by_multi_columns,
search_by_project_name=search_by_project_name,
Expand Down
Loading
Loading