1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat: archived projects query improved (#7866)

This commit is contained in:
Mateusz Kwasniewski 2024-08-14 11:01:17 +02:00 committed by GitHub
parent 778413d4c0
commit b042afb7dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 2 deletions

View File

@ -306,6 +306,13 @@ test('should archive project', async () => {
const projects = await projectService.getProjects();
expect(projects.find((p) => p.id === project.id)).toBeUndefined();
expect(projects.length).not.toBe(0);
const archivedProjects = await projectService.getProjects({
archived: true,
});
expect(archivedProjects).toMatchObject([
{ id: 'test-archive', archivedAt: expect.any(Date) },
]);
});
test('should revive project', async () => {

View File

@ -140,8 +140,8 @@ class ProjectStore implements IProjectStore {
}
}
if (query) {
projects = projects.where(query);
if (query?.id) {
projects = projects.where(`${TABLE}.id`, query.id);
}
let selectColumns = [
@ -156,6 +156,10 @@ class ProjectStore implements IProjectStore {
'project_stats.avg_time_to_prod_current_window',
] as (string | Raw<any>)[];
if (this.flagResolver.isEnabled('archiveProjects')) {
selectColumns.push(`${TABLE}.archived_at`);
}
let groupByColumns = [
'projects.id',
'project_settings.default_stickiness',
@ -219,6 +223,7 @@ class ProjectStore implements IProjectStore {
memberCount: Number(row.number_of_users) || 0,
updatedAt: row.updated_at,
createdAt: row.created_at,
archivedAt: row.archived_at,
mode: row.project_mode || 'open',
defaultStickiness: row.default_stickiness || 'default',
avgTimeToProduction: row.avg_time_to_prod_current_window || 0,

View File

@ -64,6 +64,12 @@ export const projectSchema = {
description: 'When this project was last updated.',
example: '2023-07-28T12:12:28Z',
},
archivedAt: {
type: 'string',
format: 'date-time',
description: 'When this project was archived.',
example: '2023-07-28T12:12:28Z',
},
favorite: {
type: 'boolean',
example: true,

View File

@ -573,6 +573,7 @@ export interface IProjectWithCount extends IProject {
memberCount: number;
favorite?: boolean;
avgTimeToProduction: number;
archivedAt?: Date;
}
export interface IClientSegment {