Skip to content

Commit

Permalink
add lastupdate to health report
Browse files Browse the repository at this point in the history
  • Loading branch information
ykhedher committed Nov 30, 2021
1 parent 991a4a8 commit 10c1b56
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib/db/project-store.ts
Expand Up @@ -11,7 +11,14 @@ import {
} from '../types/stores/project-store';
import { DEFAULT_ENV } from '../util/constants';

const COLUMNS = ['id', 'name', 'description', 'created_at', 'health'];
const COLUMNS = [
'id',
'name',
'description',
'created_at',
'health',
'last_update',
];
const TABLE = 'projects';

class ProjectStore implements IProjectStore {
Expand All @@ -30,6 +37,7 @@ class ProjectStore implements IProjectStore {
id: data.id,
name: data.name,
description: data.description,
lastUpdate: data.lastUpdate,
};
}

Expand Down Expand Up @@ -74,7 +82,7 @@ class ProjectStore implements IProjectStore {
async updateHealth(healthUpdate: IProjectHealthUpdate): Promise<void> {
await this.db(TABLE)
.where({ id: healthUpdate.id })
.update({ health: healthUpdate.health });
.update({ health: healthUpdate.health, last_update: new Date() });
}

async create(project: IProjectInsert): Promise<IProject> {
Expand Down Expand Up @@ -197,6 +205,7 @@ class ProjectStore implements IProjectStore {
description: row.description,
createdAt: row.created_at,
health: row.health || 100,
lastUpdate: row.last_update || new Date(),
};
}
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/services/project-health-service.ts
Expand Up @@ -72,6 +72,7 @@ export default class ProjectHealthService {
name: project.name,
description: project.description,
health: project.health,
lastUpdate: project.lastUpdate,
environments,
features,
members,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types/model.ts
Expand Up @@ -143,6 +143,7 @@ export interface IProjectOverview {
members: number;
version: number;
health: number;
lastUpdate?: Date;
}

export interface IProjectHealthReport extends IProjectOverview {
Expand Down Expand Up @@ -309,6 +310,7 @@ export interface IProject {
description: string;
health?: number;
createdAt?: Date;
lastUpdate?: Date;
}

export interface IProjectWithCount extends IProject {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types/stores/project-store.ts
@@ -1,10 +1,12 @@
import { DateFileAppender } from 'log4js';
import { IProject } from '../model';
import { Store } from './store';

export interface IProjectInsert {
id: string;
name: string;
description: string;
lastUpdate?: Date;
}

export interface IProjectArchived {
Expand Down

0 comments on commit 10c1b56

Please sign in to comment.