Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(api): only apply task pagination when explicitly requested

Andrejeed1c352e19c
diff --git a/apps/api/src/task/controllers/get-tasks.ts b/apps/api/src/task/controllers/get-tasks.ts
index a75a8d6dd..b62fc5757 100644
--- a/apps/api/src/task/controllers/get-tasks.ts
+++ b/apps/api/src/task/controllers/get-tasks.ts
@@ -102,6 +102,7 @@ async function getTasks(projectId: string, options: GetTasksOptions = {}) {
}
const whereClause = and(...conditions);
+ const usePagination = options.page != null || options.limit != null;
const page = options.page && options.page > 0 ? options.page : 1;
const pageSize =
options.limit && options.limit > 0 ? Math.min(options.limit, 100) : 50;
@@ -136,15 +137,17 @@ async function getTasks(projectId: string, options: GetTasksOptions = {}) {
projectId: taskTable.projectId,
};
- const paginatedTasks = await db
+ const query = db
.select(taskSelection)
.from(taskTable)
.leftJoin(userTable, eq(taskTable.userId, userTable.id))
.leftJoin(projectTable, eq(taskTable.projectId, projectTable.id))
.where(whereClause)
- .orderBy(orderByClause)
- .limit(pageSize)
- .offset(offset);
+ .orderBy(orderByClause);
+
+ const paginatedTasks = usePagination
+ ? await query.limit(pageSize).offset(offset)
+ : await query;
const taskIds = paginatedTasks.map((task) => task.id);
@@ -259,12 +262,19 @@ async function getTasks(projectId: string, options: GetTasksOptions = {}) {
archivedTasks,
plannedTasks,
},
- pagination: {
- total,
- page,
- pageSize,
- totalPages: Math.max(1, Math.ceil(total / pageSize)),
- },
+ pagination: usePagination
+ ? {
+ total,
+ page,
+ pageSize,
+ totalPages: Math.max(1, Math.ceil(total / pageSize)),
+ }
+ : {
+ total,
+ page: 1,
+ pageSize: total,
+ totalPages: 1,
+ },
};
}
diff --git a/apps/web/src/hooks/mutations/label/use-create-label.ts b/apps/web/src/hooks/mutations/label/use-create-label.ts
index 413561ecb..a43efca68 100644
--- a/apps/web/src/hooks/mutations/label/use-create-label.ts
+++ b/apps/web/src/hooks/mutations/label/use-create-label.ts
@@ -1,6 +1,6 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import createLabel from "@/fetchers/label/create-label";
import type { CreateLabelRequest } from "@/fetchers/label/create-label";
+import createLabel from "@/fetchers/label/create-label";
function useCreateLabel() {
const queryClient = useQueryClient();