Skip to content

Commit

Permalink
feat: query archived projects (#7862)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Aug 13, 2024
1 parent 8ce594b commit 4738d4a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/lib/features/project/project-store-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface IProjectHealthUpdate {

export interface IProjectQuery {
id?: string;
archived?: boolean;
}

export type ProjectEnvironment = {
Expand Down
6 changes: 5 additions & 1 deletion src/lib/features/project/project-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ class ProjectStore implements IProjectStore {
.orderBy('projects.name', 'asc');

if (this.flagResolver.isEnabled('archiveProjects')) {
projects = projects.where(`${TABLE}.archived_at`, null);
if (query?.archived === true) {
projects = projects.whereNot(`${TABLE}.archived_at`, null);
} else {
projects = projects.where(`${TABLE}.archived_at`, null);
}
}

if (query) {
Expand Down
11 changes: 9 additions & 2 deletions src/test/fixtures/fake-project-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
IProjectApplicationsSearchParams,
IProjectHealthUpdate,
IProjectInsert,
IProjectQuery,
ProjectEnvironment,
} from '../../lib/features/project/project-store-type';

Expand Down Expand Up @@ -48,9 +49,15 @@ export default class FakeProjectStore implements IProjectStore {
this.projectEnvironment.set(id, environments);
}

async getProjectsWithCounts(): Promise<IProjectWithCount[]> {
async getProjectsWithCounts(
query?: IProjectQuery,
): Promise<IProjectWithCount[]> {
return this.projects
.filter((project) => project.archivedAt === null)
.filter((project) =>
query?.archived
? project.archivedAt !== null
: project.archivedAt === null,
)
.map((project) => {
return {
...project,
Expand Down

0 comments on commit 4738d4a

Please sign in to comment.