-
Notifications
You must be signed in to change notification settings - Fork 205
feat: org projects pagination and add archived pagination #2312
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
base: main
Are you sure you want to change the base?
Changes from all commits
2a058be
82cc38d
11e460c
cc9a62c
86048c1
655b053
4f4c679
7287571
6ad7ee1
c8bbb97
1934704
96bd510
59900a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ import { CARD_LIMIT, Dependencies } from '$lib/constants'; | |
| import type { PageLoad } from './$types'; | ||
| import { redirect } from '@sveltejs/kit'; | ||
| import { base } from '$app/paths'; | ||
| import { isCloud } from '$lib/system'; | ||
|
|
||
| export const load: PageLoad = async ({ params, url, route, depends, parent }) => { | ||
| const { scopes } = await parent(); | ||
|
|
@@ -20,26 +19,69 @@ export const load: PageLoad = async ({ params, url, route, depends, parent }) => | |
| const offset = pageToOffset(page, limit); | ||
| const search = getSearch(url); | ||
|
|
||
| const projects = await sdk.forConsole.projects.list({ | ||
| queries: [ | ||
| Query.offset(offset), | ||
| Query.equal('teamId', params.organization), | ||
| Query.limit(limit), | ||
| Query.orderDesc(''), | ||
| Query.select(['$id', 'name', 'platforms', 'region', ...(isCloud ? ['status'] : [])]) | ||
| ], | ||
| search: search || undefined | ||
| }); | ||
| const archivedPageRaw = parseInt(url.searchParams.get('archivedPage') || '1', 10); | ||
| const archivedPage = | ||
| Number.isFinite(archivedPageRaw) && archivedPageRaw > 0 ? archivedPageRaw : 1; | ||
| const archivedOffset = pageToOffset(archivedPage, limit); | ||
| const [activeProjects, archivedProjects, activeTotal, archivedTotal] = await Promise.all([ | ||
| sdk.forConsole.projects.list({ | ||
| queries: [ | ||
| Query.offset(offset), | ||
| Query.equal('teamId', params.organization), | ||
| Query.or([Query.equal('status', 'active'), Query.isNull('status')]), | ||
| Query.limit(limit), | ||
| Query.orderDesc('') | ||
| ], | ||
| search: search || undefined | ||
| }), | ||
| sdk.forConsole.projects.list({ | ||
| queries: [ | ||
| Query.offset(archivedOffset), | ||
| Query.equal('teamId', params.organization), | ||
| Query.equal('status', 'archived'), | ||
| Query.limit(limit), | ||
| Query.orderDesc('') | ||
| ], | ||
| search: search || undefined | ||
| }), | ||
| sdk.forConsole.projects.list({ | ||
| queries: [ | ||
| Query.equal('teamId', params.organization), | ||
| Query.or([Query.equal('status', 'active'), Query.isNull('status')]) | ||
| ], | ||
| search: search || undefined | ||
| }), | ||
| sdk.forConsole.projects.list({ | ||
| queries: [ | ||
| Query.equal('teamId', params.organization), | ||
| Query.equal('status', 'archived') | ||
| ], | ||
| search: search || undefined | ||
| }) | ||
| ]); | ||
|
Comment on lines
+26
to
+61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainOptional: verify Empty field name may be ignored or error depending on SDK version. Confirm intended default ordering or set an explicit field (e.g., createdAt/updatedAt). 🌐 Web query: 💡 Result: No — an empty string is not a valid field for Query.orderDesc(''). To sort by most-recently-created use the created timestamp field (Appwrite exposes $createdAt). Example: Query.orderDesc('$createdAt') — (escape the $ if your language/string parser requires, e.g. '$createdAt' in Flutter). You can also use $sequence for insertion order if preferred. [1][2][3] Use explicit timestamp field in Query.orderDesc 🤖 Prompt for AI Agents |
||
|
|
||
| // set `default` if no region! | ||
| for (const project of projects.projects) { | ||
| for (const project of activeProjects.projects) { | ||
| project.region ??= 'default'; | ||
| } | ||
| for (const project of archivedProjects.projects) { | ||
| project.region ??= 'default'; | ||
| } | ||
|
|
||
| return { | ||
| offset, | ||
| limit, | ||
| projects, | ||
| projects: { | ||
| ...activeProjects, | ||
| projects: activeProjects.projects, | ||
| total: activeTotal.total | ||
| }, | ||
| activeProjectsPage: activeProjects.projects, | ||
| archivedProjectsPage: archivedProjects.projects, | ||
| activeTotalOverall: activeTotal.total, | ||
| archivedTotalOverall: archivedTotal.total, | ||
| archivedOffset, | ||
| archivedPage, | ||
| search | ||
| }; | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.