1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-12 13:48:35 +02:00

feat: query archived projects (#7862)

This commit is contained in:
Mateusz Kwasniewski 2024-08-13 15:33:31 +02:00 committed by GitHub
parent 8ce594ba52
commit 4738d4a61f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 3 deletions

View File

@ -47,6 +47,7 @@ export interface IProjectHealthUpdate {
export interface IProjectQuery { export interface IProjectQuery {
id?: string; id?: string;
archived?: boolean;
} }
export type ProjectEnvironment = { export type ProjectEnvironment = {

View File

@ -133,7 +133,11 @@ class ProjectStore implements IProjectStore {
.orderBy('projects.name', 'asc'); .orderBy('projects.name', 'asc');
if (this.flagResolver.isEnabled('archiveProjects')) { 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) { if (query) {

View File

@ -16,6 +16,7 @@ import type {
IProjectApplicationsSearchParams, IProjectApplicationsSearchParams,
IProjectHealthUpdate, IProjectHealthUpdate,
IProjectInsert, IProjectInsert,
IProjectQuery,
ProjectEnvironment, ProjectEnvironment,
} from '../../lib/features/project/project-store-type'; } from '../../lib/features/project/project-store-type';
@ -48,9 +49,15 @@ export default class FakeProjectStore implements IProjectStore {
this.projectEnvironment.set(id, environments); this.projectEnvironment.set(id, environments);
} }
async getProjectsWithCounts(): Promise<IProjectWithCount[]> { async getProjectsWithCounts(
query?: IProjectQuery,
): Promise<IProjectWithCount[]> {
return this.projects return this.projects
.filter((project) => project.archivedAt === null) .filter((project) =>
query?.archived
? project.archivedAt !== null
: project.archivedAt === null,
)
.map((project) => { .map((project) => {
return { return {
...project, ...project,