1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-22 01:16:07 +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 {
id?: string;
archived?: boolean;
}
export type ProjectEnvironment = {

View File

@ -133,8 +133,12 @@ class ProjectStore implements IProjectStore {
.orderBy('projects.name', 'asc');
if (this.flagResolver.isEnabled('archiveProjects')) {
if (query?.archived === true) {
projects = projects.whereNot(`${TABLE}.archived_at`, null);
} else {
projects = projects.where(`${TABLE}.archived_at`, null);
}
}
if (query) {
projects = projects.where(query);

View File

@ -16,6 +16,7 @@ import type {
IProjectApplicationsSearchParams,
IProjectHealthUpdate,
IProjectInsert,
IProjectQuery,
ProjectEnvironment,
} from '../../lib/features/project/project-store-type';
@ -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,