1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

feat[hack]: Add last usage and last update metrics to project list payload

This is a proof of concept and probably not how we want to do it in
the end. However, it can serve as a useful bit of information on what
tables to query, what joins to make etc.
This commit is contained in:
Thomas Heartman 2024-08-15 11:09:24 +02:00
parent 3baeb4c541
commit b7534bfa07
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78
2 changed files with 10 additions and 1 deletions

View File

@ -130,6 +130,7 @@ class ProjectStore implements IProjectStore {
'projects.id',
)
.leftJoin('project_stats', 'project_stats.project', 'projects.id')
.leftJoin('events', 'events.feature_name', 'features.name')
.orderBy('projects.name', 'asc');
if (this.flagResolver.isEnabled('archiveProjects')) {
@ -149,7 +150,9 @@ class ProjectStore implements IProjectStore {
'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, ' +
'count(features.name) FILTER (WHERE features.archived_at is null and features.stale IS TRUE) AS stale_feature_count, ' +
'count(features.name) FILTER (WHERE features.archived_at is null and features.potentially_stale IS TRUE) AS potentially_stale_feature_count',
'count(features.name) FILTER (WHERE features.archived_at is null and features.potentially_stale IS TRUE) AS potentially_stale_feature_count,' +
'MAX(features.last_seen_at) AS last_usage,' +
'MAX(events.created_at) AS last_updated',
),
'project_settings.default_stickiness',
'project_settings.project_mode',
@ -191,6 +194,8 @@ class ProjectStore implements IProjectStore {
const projectsWithFeatureCount = projectAndFeatureCount.map(
this.mapProjectWithCountRow,
);
console.log('projectsWithFeatureCount', projectsWithFeatureCount);
projectTimer();
const memberTimer = this.timer('getMemberCount');
@ -227,6 +232,8 @@ class ProjectStore implements IProjectStore {
mode: row.project_mode || 'open',
defaultStickiness: row.default_stickiness || 'default',
avgTimeToProduction: row.avg_time_to_prod_current_window || 0,
lastUsage: row.last_usage,
lastUpdated: row.last_updated,
};
}

View File

@ -574,6 +574,8 @@ export interface IProjectWithCount extends IProject {
favorite?: boolean;
avgTimeToProduction: number;
archivedAt?: Date;
lastUsage?: Date;
lastUpdated?: Date;
}
export interface IClientSegment {