1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

fix: add createdAt in projects API response (#3929)

This PR adds the "createdAt" field to the /api/projects response, so
that we are compliant with the schema.
This commit is contained in:
Ivar Conradi Østhus 2023-06-09 16:18:38 +02:00 committed by GitHub
parent 27093de97e
commit 1bc130b7f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 1 deletions

View File

@ -107,7 +107,7 @@ class ProjectStore implements IProjectStore {
}
let selectColumns = [
this.db.raw(
'projects.id, projects.name, projects.description, projects.health, projects.updated_at, count(features.name) FILTER (WHERE features.archived_at is null) AS number_of_features',
'projects.id, projects.name, projects.description, projects.health, projects.updated_at, projects.created_at, count(features.name) FILTER (WHERE features.archived_at is null) AS number_of_features',
),
] as (string | Raw<any>)[];
@ -164,6 +164,7 @@ class ProjectStore implements IProjectStore {
featureCount: Number(row.number_of_features) || 0,
memberCount: Number(row.number_of_users) || 0,
updatedAt: row.updated_at,
createdAt: row.created_at,
mode: 'open',
defaultStickiness: 'default',
};

View File

@ -91,6 +91,13 @@ export const healthOverviewSchema = {
description: 'When the project was last updated.',
example: '2023-04-19T08:15:14.000Z',
},
createdAt: {
type: 'string',
format: 'date-time',
nullable: true,
description: 'When the project was last updated.',
example: '2023-04-19T08:15:14.000Z',
},
favorite: {
type: 'boolean',
description:

View File

@ -98,6 +98,12 @@ export const projectOverviewSchema = {
nullable: true,
example: '2023-02-10T08:36:35.262Z',
},
createdAt: {
type: 'string',
format: 'date-time',
nullable: true,
example: '2023-02-10T08:36:35.262Z',
},
favorite: {
type: 'boolean',
example: true,

View File

@ -840,6 +840,7 @@ export default class ProjectService {
health: project.health || 0,
favorite: favorite,
updatedAt: project.updatedAt,
createdAt: project.createdAt,
environments,
features,
members,

View File

@ -193,6 +193,7 @@ export interface IProjectOverview {
health: number;
favorite?: boolean;
updatedAt?: Date;
createdAt: Date | undefined;
stats?: IProjectStats;
mode: ProjectMode;

View File

@ -42,3 +42,19 @@ test('Should ONLY return default project', async () => {
expect(body.projects).toHaveLength(1);
expect(body.projects[0].id).toBe('default');
});
test('response should include created_at', async () => {
const { body } = await app.request
.get('/api/admin/projects')
.expect('Content-Type', /json/)
.expect(200);
expect(body.projects[0].createdAt).toBeDefined();
});
test('response for default project should include created_at', async () => {
const { body } = await app.request
.get('/api/admin/projects/default')
.expect('Content-Type', /json/)
.expect(200);
expect(body.createdAt).toBeDefined();
});

View File

@ -2758,6 +2758,13 @@ The provider you choose for your addon dictates what properties the \`parameters
"additionalProperties": false,
"description": "An overview of a project's stats and its health as described in the documentation on [technical debt](https://docs.getunleash.io/reference/technical-debt)",
"properties": {
"createdAt": {
"description": "When the project was last updated.",
"example": "2023-04-19T08:15:14.000Z",
"format": "date-time",
"nullable": true,
"type": "string",
},
"defaultStickiness": {
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
"example": "userId",
@ -2851,6 +2858,13 @@ The provider you choose for your addon dictates what properties the \`parameters
"example": 2,
"type": "number",
},
"createdAt": {
"description": "When the project was last updated.",
"example": "2023-04-19T08:15:14.000Z",
"format": "date-time",
"nullable": true,
"type": "string",
},
"defaultStickiness": {
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
"example": "userId",
@ -3780,6 +3794,12 @@ The provider you choose for your addon dictates what properties the \`parameters
"additionalProperties": false,
"description": "A high-level overview of a project. It contains information such as project statistics, the name of the project, what members and what features it contains, etc.",
"properties": {
"createdAt": {
"example": "2023-02-10T08:36:35.262Z",
"format": "date-time",
"nullable": true,
"type": "string",
},
"defaultStickiness": {
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
"example": "userId",