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:
parent
27093de97e
commit
1bc130b7f0
@ -107,7 +107,7 @@ class ProjectStore implements IProjectStore {
|
|||||||
}
|
}
|
||||||
let selectColumns = [
|
let selectColumns = [
|
||||||
this.db.raw(
|
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>)[];
|
] as (string | Raw<any>)[];
|
||||||
|
|
||||||
@ -164,6 +164,7 @@ class ProjectStore implements IProjectStore {
|
|||||||
featureCount: Number(row.number_of_features) || 0,
|
featureCount: Number(row.number_of_features) || 0,
|
||||||
memberCount: Number(row.number_of_users) || 0,
|
memberCount: Number(row.number_of_users) || 0,
|
||||||
updatedAt: row.updated_at,
|
updatedAt: row.updated_at,
|
||||||
|
createdAt: row.created_at,
|
||||||
mode: 'open',
|
mode: 'open',
|
||||||
defaultStickiness: 'default',
|
defaultStickiness: 'default',
|
||||||
};
|
};
|
||||||
|
@ -91,6 +91,13 @@ export const healthOverviewSchema = {
|
|||||||
description: 'When the project was last updated.',
|
description: 'When the project was last updated.',
|
||||||
example: '2023-04-19T08:15:14.000Z',
|
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: {
|
favorite: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description:
|
description:
|
||||||
|
@ -98,6 +98,12 @@ export const projectOverviewSchema = {
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
example: '2023-02-10T08:36:35.262Z',
|
example: '2023-02-10T08:36:35.262Z',
|
||||||
},
|
},
|
||||||
|
createdAt: {
|
||||||
|
type: 'string',
|
||||||
|
format: 'date-time',
|
||||||
|
nullable: true,
|
||||||
|
example: '2023-02-10T08:36:35.262Z',
|
||||||
|
},
|
||||||
favorite: {
|
favorite: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
example: true,
|
example: true,
|
||||||
|
@ -840,6 +840,7 @@ export default class ProjectService {
|
|||||||
health: project.health || 0,
|
health: project.health || 0,
|
||||||
favorite: favorite,
|
favorite: favorite,
|
||||||
updatedAt: project.updatedAt,
|
updatedAt: project.updatedAt,
|
||||||
|
createdAt: project.createdAt,
|
||||||
environments,
|
environments,
|
||||||
features,
|
features,
|
||||||
members,
|
members,
|
||||||
|
@ -193,6 +193,7 @@ export interface IProjectOverview {
|
|||||||
health: number;
|
health: number;
|
||||||
favorite?: boolean;
|
favorite?: boolean;
|
||||||
updatedAt?: Date;
|
updatedAt?: Date;
|
||||||
|
createdAt: Date | undefined;
|
||||||
stats?: IProjectStats;
|
stats?: IProjectStats;
|
||||||
mode: ProjectMode;
|
mode: ProjectMode;
|
||||||
|
|
||||||
|
@ -42,3 +42,19 @@ test('Should ONLY return default project', async () => {
|
|||||||
expect(body.projects).toHaveLength(1);
|
expect(body.projects).toHaveLength(1);
|
||||||
expect(body.projects[0].id).toBe('default');
|
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();
|
||||||
|
});
|
||||||
|
@ -2758,6 +2758,13 @@ The provider you choose for your addon dictates what properties the \`parameters
|
|||||||
"additionalProperties": false,
|
"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)",
|
"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": {
|
"properties": {
|
||||||
|
"createdAt": {
|
||||||
|
"description": "When the project was last updated.",
|
||||||
|
"example": "2023-04-19T08:15:14.000Z",
|
||||||
|
"format": "date-time",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"defaultStickiness": {
|
"defaultStickiness": {
|
||||||
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
|
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
|
||||||
"example": "userId",
|
"example": "userId",
|
||||||
@ -2851,6 +2858,13 @@ The provider you choose for your addon dictates what properties the \`parameters
|
|||||||
"example": 2,
|
"example": 2,
|
||||||
"type": "number",
|
"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": {
|
"defaultStickiness": {
|
||||||
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
|
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
|
||||||
"example": "userId",
|
"example": "userId",
|
||||||
@ -3780,6 +3794,12 @@ The provider you choose for your addon dictates what properties the \`parameters
|
|||||||
"additionalProperties": false,
|
"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.",
|
"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": {
|
"properties": {
|
||||||
|
"createdAt": {
|
||||||
|
"example": "2023-02-10T08:36:35.262Z",
|
||||||
|
"format": "date-time",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"defaultStickiness": {
|
"defaultStickiness": {
|
||||||
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
|
"description": "A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy",
|
||||||
"example": "userId",
|
"example": "userId",
|
||||||
|
Loading…
Reference in New Issue
Block a user