Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pagination removal and local indexDB for issues #5360

Draft
wants to merge 2 commits into
base: preview
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions apiserver/plane/app/urls/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
LabelViewSet,
BulkIssueOperationsEndpoint,
BulkArchiveIssuesEndpoint,
DeletedIssuesListViewSet,
)

urlpatterns = [
Expand Down Expand Up @@ -310,4 +311,9 @@
BulkIssueOperationsEndpoint.as_view(),
name="bulk-operations-issues",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/deleted-issues/",
DeletedIssuesListViewSet.as_view(),
name="deleted-issues",
),
]
1 change: 1 addition & 0 deletions apiserver/plane/app/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
IssueViewSet,
IssueUserDisplayPropertyEndpoint,
BulkDeleteIssuesEndpoint,
DeletedIssuesListViewSet,
)

from .issue.activity import (
Expand Down
24 changes: 23 additions & 1 deletion apiserver/plane/app/views/issue/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,17 @@ def get_queryset(self):

@method_decorator(gzip_page)
def list(self, request, slug, project_id):
extra_filters = {}
if request.GET.get("updated_at__gt", None) is not None:
extra_filters = {
"updated_at__gt": request.GET.get("updated_at__gt")
}

print (extra_filters)
filters = issue_filters(request.query_params, "GET")
order_by_param = request.GET.get("order_by", "-created_at")

issue_queryset = self.get_queryset().filter(**filters)
issue_queryset = self.get_queryset().filter(**filters, **extra_filters)
# Custom ordering for priority and state

# Issue queryset
Expand Down Expand Up @@ -652,3 +659,18 @@ def delete(self, request, slug, project_id):
{"message": f"{total_issues} issues were deleted"},
status=status.HTTP_200_OK,
)


class DeletedIssuesListViewSet(BaseAPIView):
permission_classes = [
ProjectEntityPermission,
]

def get(self, request, slug, project_id):
deleted_issues = Issue.all_objects.filter(
workspace__slug=slug,
project_id=project_id,
deleted_at__isnull=False,
).values_list("id", flat=True)

return Response(deleted_issues, status=status.HTTP_200_OK)
5 changes: 0 additions & 5 deletions apiserver/plane/authentication/views/app/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
AuthenticationException,
AUTHENTICATION_ERROR_CODES,
)
from plane.authentication.rate_limit import AuthenticationThrottle


class MagicGenerateEndpoint(APIView):
Expand All @@ -38,10 +37,6 @@ class MagicGenerateEndpoint(APIView):
AllowAny,
]

throttle_classes = [
AuthenticationThrottle,
]

def post(self, request):
# Check if instance is configured
instance = Instance.objects.first()
Expand Down
13 changes: 8 additions & 5 deletions apiserver/plane/space/views/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ def get(self, request, anchor):
status=status.HTTP_404_NOT_FOUND,
)

states = State.objects.filter(
~Q(name="Triage"),
workspace__slug=deploy_board.workspace.slug,
project_id=deploy_board.project_id,
).values("name", "group", "color", "id", "sequence")
states = (
State.objects.filter(
~Q(name="Triage"),
workspace__slug=deploy_board.workspace.slug,
project_id=deploy_board.project_id,
)
.values("name", "group", "color", "id")
)

return Response(
states,
Expand Down
10 changes: 5 additions & 5 deletions apiserver/plane/utils/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __repr__(self):
return f"<{type(self).__name__}: results={len(self.results)}>"


MAX_LIMIT = 100
MAX_LIMIT = 1000


class BadPaginationError(Exception):
Expand Down Expand Up @@ -118,7 +118,7 @@ def __init__(
self.max_offset = max_offset
self.on_results = on_results

def get_result(self, limit=100, cursor=None):
def get_result(self, limit=1000, cursor=None):
# offset is page #
# value is page limit
if cursor is None:
Expand Down Expand Up @@ -727,7 +727,7 @@ class BasePaginator:
cursor_name = "cursor"

# get the per page parameter from request
def get_per_page(self, request, default_per_page=100, max_per_page=100):
def get_per_page(self, request, default_per_page=1000, max_per_page=1000):
try:
per_page = int(request.GET.get("per_page", default_per_page))
except ValueError:
Expand All @@ -747,8 +747,8 @@ def paginate(
on_results=None,
paginator=None,
paginator_cls=OffsetPaginator,
default_per_page=100,
max_per_page=100,
default_per_page=1000,
max_per_page=1000,
cursor_cls=Cursor,
extra_stats=None,
controller=None,
Expand Down
8 changes: 5 additions & 3 deletions packages/types/src/issues/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ export * from "./issue_relation";
export * from "./issue_sub_issues";
export * from "./activity/base";

export type TLoader = "init-loader" | "mutation" | "pagination" | undefined;
export type TLoader = "init-loader" | "mutation" | undefined;

export type TUngroupedIssues = string[];

export type TGroupedIssues = {
[group_id: string]: string[];
[group_id: string]: TUngroupedIssues;
};

export type TSubGroupedIssues = {
[sub_grouped_id: string]: TGroupedIssues;
};

export type TIssues = TGroupedIssues | TSubGroupedIssues;
export type TIssues = TGroupedIssues | TSubGroupedIssues | TUngroupedIssues;

export type TPaginationData = {
nextCursor: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export const ProjectArchivesHeader: FC<TProps> = observer((props: TProps) => {
const { workspaceSlug, projectId } = useParams();
// store hooks
const {
issues: { getGroupIssueCount },
issues: { issueIds },
} = useIssues(EIssuesStoreType.ARCHIVED);
const { currentProjectDetails, loader } = useProject();
// hooks
const { isMobile } = usePlatformOS();

const issueCount = getGroupIssueCount(undefined, undefined, false);
const issueCount = issueIds?.length;

const activeTabBreadcrumbDetail =
PROJECT_ARCHIVES_BREADCRUMB_LIST[activeTab as keyof typeof PROJECT_ARCHIVES_BREADCRUMB_LIST];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const CycleIssuesHeader: React.FC = observer(() => {
// store hooks
const {
issuesFilter: { issueFilters, updateFilters },
issues: { getGroupIssueCount },
issues: { issueIds },
} = useIssues(EIssuesStoreType.CYCLE);
const { currentProjectCycleIds, getCycleById } = useCycle();
const { toggleCreateIssueModal } = useCommandPalette();
Expand Down Expand Up @@ -152,7 +152,7 @@ export const CycleIssuesHeader: React.FC = observer(() => {
const canUserCreateIssue =
currentProjectRole && [EUserProjectRoles.ADMIN, EUserProjectRoles.MEMBER].includes(currentProjectRole);

const issuesCount = getGroupIssueCount(undefined, undefined, false);
const issuesCount = issueIds?.length;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ProjectIssuesHeader = observer(() => {
} = useMember();
const {
issuesFilter: { issueFilters, updateFilters },
issues: { getGroupIssueCount },
issues: { issueIds },
} = useIssues(EIssuesStoreType.PROJECT);
const { toggleCreateIssueModal } = useCommandPalette();
const { setTrackElement } = useEventTracker();
Expand Down Expand Up @@ -113,7 +113,7 @@ export const ProjectIssuesHeader = observer(() => {
const canUserCreateIssue =
currentProjectRole && [EUserProjectRoles.ADMIN, EUserProjectRoles.MEMBER].includes(currentProjectRole);

const issuesCount = getGroupIssueCount(undefined, undefined, false);
const issuesCount = issueIds?.length;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
// store hooks
const {
issuesFilter: { issueFilters },
issues: { getGroupIssueCount },
issues: { issueIds },
} = useIssues(EIssuesStoreType.MODULE);
const { updateFilters } = useIssuesActions(EIssuesStoreType.MODULE);
const { projectModuleIds, getModuleById } = useModule();
Expand Down Expand Up @@ -152,7 +152,7 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
const canUserCreateIssue =
currentProjectRole && [EUserProjectRoles.ADMIN, EUserProjectRoles.MEMBER].includes(currentProjectRole);

const issuesCount = getGroupIssueCount(undefined, undefined, false);
const issuesCount = issueIds?.length;

return (
<>
Expand Down
4 changes: 3 additions & 1 deletion web/core/components/core/render-if-visible-HOC.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Props = {
as?: keyof JSX.IntrinsicElements;
classNames?: string;
placeholderChildren?: ReactNode;
shouldRenderByDefault?: boolean;
};

const RenderIfVisible: React.FC<Props> = (props) => {
Expand All @@ -22,8 +23,9 @@ const RenderIfVisible: React.FC<Props> = (props) => {
children,
classNames = "",
placeholderChildren = null, //placeholder children
shouldRenderByDefault = false,
} = props;
const [shouldVisible, setShouldVisible] = useState<boolean>();
const [shouldVisible, setShouldVisible] = useState<boolean>(shouldRenderByDefault);
const placeholderHeight = useRef<string>(defaultHeight);
const intersectionRef = useRef<HTMLElement | null>(null);

Expand Down
66 changes: 30 additions & 36 deletions web/core/components/gantt-chart/chart/main-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import { useGanttChart } from "../hooks/use-gantt-chart";
type Props = {
blockIds: string[];
getBlockById: (id: string, currentViewData?: ChartDataType | undefined) => IGanttBlock;
canLoadMoreBlocks?: boolean;
loadMoreBlocks?: () => void;
blockToRender: (data: any) => React.ReactNode;
blockUpdateHandler: (block: any, payload: IBlockUpdateData) => void;
bottomSpacing: boolean;
Expand All @@ -56,7 +54,6 @@ export const GanttChartMainContent: React.FC<Props> = observer((props) => {
const {
blockIds,
getBlockById,
loadMoreBlocks,
blockToRender,
blockUpdateHandler,
bottomSpacing,
Expand All @@ -70,7 +67,6 @@ export const GanttChartMainContent: React.FC<Props> = observer((props) => {
showAllBlocks,
sidebarToRender,
title,
canLoadMoreBlocks,
updateCurrentViewRenderPayload,
quickAdd,
} = props;
Expand Down Expand Up @@ -145,38 +141,36 @@ export const GanttChartMainContent: React.FC<Props> = observer((props) => {
onScroll={onScroll}
>
<GanttChartSidebar
blockIds={blockIds}
getBlockById={getBlockById}
loadMoreBlocks={loadMoreBlocks}
canLoadMoreBlocks={canLoadMoreBlocks}
ganttContainerRef={ganttContainerRef}
blockUpdateHandler={blockUpdateHandler}
enableReorder={enableReorder}
enableSelection={enableSelection}
sidebarToRender={sidebarToRender}
title={title}
quickAdd={quickAdd}
selectionHelpers={helpers}
/>
<div className="relative min-h-full h-max flex-shrink-0 flex-grow">
<ActiveChartView />
{currentViewData && (
<GanttChartBlocksList
itemsContainerWidth={itemsContainerWidth}
blockIds={blockIds}
getBlockById={getBlockById}
blockToRender={blockToRender}
blockUpdateHandler={blockUpdateHandler}
enableBlockLeftResize={enableBlockLeftResize}
enableBlockRightResize={enableBlockRightResize}
enableBlockMove={enableBlockMove}
enableAddBlock={enableAddBlock}
ganttContainerRef={ganttContainerRef}
showAllBlocks={showAllBlocks}
selectionHelpers={helpers}
/>
)}
</div>
blockIds={blockIds}
getBlockById={getBlockById}
ganttContainerRef={ganttContainerRef}
blockUpdateHandler={blockUpdateHandler}
enableReorder={enableReorder}
enableSelection={enableSelection}
sidebarToRender={sidebarToRender}
title={title}
quickAdd={quickAdd}
selectionHelpers={helpers}
/>
<div className="relative min-h-full h-max flex-shrink-0 flex-grow">
<ActiveChartView />
{currentViewData && (
<GanttChartBlocksList
itemsContainerWidth={itemsContainerWidth}
blockIds={blockIds}
getBlockById={getBlockById}
blockToRender={blockToRender}
blockUpdateHandler={blockUpdateHandler}
enableBlockLeftResize={enableBlockLeftResize}
enableBlockRightResize={enableBlockRightResize}
enableBlockMove={enableBlockMove}
enableAddBlock={enableAddBlock}
ganttContainerRef={ganttContainerRef}
showAllBlocks={showAllBlocks}
selectionHelpers={helpers}
/>
)}
</div>
</div>
<IssueBulkOperationsRoot selectionHelpers={helpers} />
</>
Expand Down
6 changes: 0 additions & 6 deletions web/core/components/gantt-chart/chart/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type ChartViewRootProps = {
bottomSpacing: boolean;
showAllBlocks: boolean;
getBlockById: (id: string, currentViewData?: ChartDataType | undefined) => IGanttBlock;
loadMoreBlocks?: () => void;
canLoadMoreBlocks?: boolean;
quickAdd?: React.JSX.Element | undefined;
};

Expand All @@ -43,12 +41,10 @@ export const ChartViewRoot: FC<ChartViewRootProps> = observer((props) => {
title,
blockIds,
getBlockById,
loadMoreBlocks,
loaderTitle,
blockUpdateHandler,
sidebarToRender,
blockToRender,
canLoadMoreBlocks,
enableBlockLeftResize,
enableBlockRightResize,
enableBlockMove,
Expand Down Expand Up @@ -165,8 +161,6 @@ export const ChartViewRoot: FC<ChartViewRootProps> = observer((props) => {
<GanttChartMainContent
blockIds={blockIds}
getBlockById={getBlockById}
loadMoreBlocks={loadMoreBlocks}
canLoadMoreBlocks={canLoadMoreBlocks}
blockToRender={blockToRender}
blockUpdateHandler={blockUpdateHandler}
bottomSpacing={bottomSpacing}
Expand Down
Loading