From 5101790229ea17e425cfa037e645057b411318bd Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Tue, 23 Dec 2025 12:05:41 +0530 Subject: [PATCH 1/3] fix: filter non archived prject --- .../(console)/organization-[organization]/+page.svelte | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/routes/(console)/organization-[organization]/+page.svelte b/src/routes/(console)/organization-[organization]/+page.svelte index 4794d86590..ae194fcfd7 100644 --- a/src/routes/(console)/organization-[organization]/+page.svelte +++ b/src/routes/(console)/organization-[organization]/+page.svelte @@ -77,6 +77,10 @@ : []; }); + const activeProjects = $derived.by(() => { + return data.projects.projects.filter((project) => project.status !== 'archived'); + }); + function filterPlatforms(platforms: { name: string; icon: string }[]) { return platforms.filter( (value, index, self) => index === self.findIndex((t) => t.name === value.name) @@ -241,7 +245,7 @@ total={data.projects.total} offset={data.offset} on:click={handleCreateProject}> - {#each data.projects.projects as project} + {#each activeProjects as project} {@const platforms = filterPlatforms( project.platforms.map((platform) => getPlatformInfo(platform.type)) )} From 94d80f7ebc1d4a5537bb6d4973eec15b5fe10bd8 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Tue, 23 Dec 2025 12:12:34 +0530 Subject: [PATCH 2/3] code rabbit suggestion --- .../(console)/organization-[organization]/+page.svelte | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/routes/(console)/organization-[organization]/+page.svelte b/src/routes/(console)/organization-[organization]/+page.svelte index ae194fcfd7..ea75d0933d 100644 --- a/src/routes/(console)/organization-[organization]/+page.svelte +++ b/src/routes/(console)/organization-[organization]/+page.svelte @@ -81,6 +81,8 @@ return data.projects.projects.filter((project) => project.status !== 'archived'); }); + const activeProjectsCount = $derived(activeProjects.length); + function filterPlatforms(platforms: { name: string; icon: string }[]) { return platforms.filter( (value, index, self) => index === self.findIndex((t) => t.name === value.name) @@ -239,10 +241,10 @@ {/if} - {#if data.projects.total > 0} + {#if activeProjectsCount > 0} {#each activeProjects as project} @@ -327,7 +329,7 @@ name="Projects" limit={data.limit} offset={data.offset} - total={data.projects.total} /> + total={activeProjectsCount} /> Date: Tue, 23 Dec 2025 12:29:08 +0530 Subject: [PATCH 3/3] corrrect pagination --- .../organization-[organization]/+page.svelte | 10 +- .../organization-[organization]/+page.ts | 100 ++++++++++++++---- 2 files changed, 82 insertions(+), 28 deletions(-) diff --git a/src/routes/(console)/organization-[organization]/+page.svelte b/src/routes/(console)/organization-[organization]/+page.svelte index ea75d0933d..bc989c5486 100644 --- a/src/routes/(console)/organization-[organization]/+page.svelte +++ b/src/routes/(console)/organization-[organization]/+page.svelte @@ -72,16 +72,12 @@ }); const projectsToArchive = $derived.by(() => { - return isCloud - ? data.projects.projects.filter((project) => project.status === 'archived') - : []; + return isCloud && data.archivedProjectsPage ? data.archivedProjectsPage : []; }); - const activeProjects = $derived.by(() => { - return data.projects.projects.filter((project) => project.status !== 'archived'); - }); + const activeProjects = $derived(data.projects.projects); - const activeProjectsCount = $derived(activeProjects.length); + const activeProjectsCount = $derived(data.projects.total); function filterPlatforms(platforms: { name: string; icon: string }[]) { return platforms.filter( diff --git a/src/routes/(console)/organization-[organization]/+page.ts b/src/routes/(console)/organization-[organization]/+page.ts index dfd1d75fa5..fc3d91c66b 100644 --- a/src/routes/(console)/organization-[organization]/+page.ts +++ b/src/routes/(console)/organization-[organization]/+page.ts @@ -20,26 +20,84 @@ 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 - }); - - // set `default` if no region! - for (const project of projects.projects) { - project.region ??= 'default'; - } + if (isCloud) { + 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.equal('teamId', params.organization), + Query.equal('status', 'archived'), + Query.limit(1000) + ], + 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 + }) + ]); + + for (const project of activeProjects.projects) { + project.region ??= 'default'; + } + for (const project of archivedProjects.projects) { + project.region ??= 'default'; + } + + return { + offset, + limit, + projects: { + ...activeProjects, + projects: activeProjects.projects, + total: activeTotal.total + }, + activeProjectsPage: activeProjects.projects, + archivedProjectsPage: archivedProjects.projects, + activeTotalOverall: activeTotal.total, + archivedTotalOverall: archivedTotal.total, + search + }; + } else { + const projects = await sdk.forConsole.projects.list({ + queries: [ + Query.offset(offset), + Query.equal('teamId', params.organization), + Query.limit(limit), + Query.orderDesc('') + ], + search: search || undefined + }); - return { - offset, - limit, - projects, - search - }; + // set `default` if no region! + for (const project of projects.projects) { + project.region ??= 'default'; + } + + return { + offset, + limit, + projects, + search + }; + } };