Skip to content

Commit

Permalink
feat: return archived at in project overview (#7888)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Aug 15, 2024
1 parent 413df42 commit 30cbde5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/lib/features/project/project-service.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ test('should archive project', async () => {
expect(archivedProjects).toMatchObject([
{ id: 'test-archive', archivedAt: expect.any(Date) },
]);

const archivedProject = await projectService.getProject(project.id);
expect(archivedProject).toMatchObject({ archivedAt: expect.any(Date) });
});

test('should revive project', async () => {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/features/project/project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,9 @@ export default class ProjectService {
health: project.health || 0,
favorite: favorite,
updatedAt: project.updatedAt,
...(this.flagResolver.isEnabled('archiveProjects')
? { archivedAt: project.archivedAt }
: {}),
createdAt: project.createdAt,
environments,
featureTypeCounts,
Expand Down
8 changes: 7 additions & 1 deletion src/lib/features/project/project-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,13 @@ class ProjectStore implements IProjectStore {
}

async get(id: string): Promise<IProject> {
let extraColumns: string[] = [];
if (this.flagResolver.isEnabled('archiveProjects')) {
extraColumns = ['archived_at'];
}

return this.db
.first([...COLUMNS, ...SETTINGS_COLUMNS])
.first([...COLUMNS, ...SETTINGS_COLUMNS, ...extraColumns])
.from(TABLE)
.leftJoin(
SETTINGS_TABLE,
Expand Down Expand Up @@ -791,6 +796,7 @@ class ProjectStore implements IProjectStore {
createdAt: row.created_at,
health: row.health ?? 100,
updatedAt: row.updated_at || new Date(),
...(row.archived_at ? { archivedAt: row.archived_at } : {}),
mode: row.project_mode || 'open',
defaultStickiness: row.default_stickiness || 'default',
featureLimit: row.feature_limit,
Expand Down
7 changes: 7 additions & 0 deletions src/lib/openapi/spec/project-overview-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ export const projectOverviewSchema = {
example: '2023-02-10T08:36:35.262Z',
description: 'When the project was last updated.',
},
archivedAt: {
type: 'string',
format: 'date-time',
nullable: true,
example: '2023-02-10T08:36:35.262Z',
description: 'When the project was archived.',
},
createdAt: {
type: 'string',
format: 'date-time',
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export interface IProjectOverview {
health: number;
favorite?: boolean;
updatedAt?: Date;
archivedAt?: Date;
createdAt: Date | undefined;
stats?: IProjectStats;
mode: ProjectMode;
Expand Down Expand Up @@ -525,6 +526,7 @@ export interface IProject {
health?: number;
createdAt?: Date;
updatedAt?: Date;
archivedAt?: Date;
changeRequestsEnabled?: boolean;
mode: ProjectMode;
defaultStickiness: string;
Expand Down

0 comments on commit 30cbde5

Please sign in to comment.