mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-04 00:18:40 +01:00
chore: minor cleanup in new project read model (#7911)
This PR touches up a few small things in the project read model. Fixes: Use the right method name in the query/method timer for `getProjectsForAdminUi`. I'd forgotten to change the timer name from the original method name. Spells the method name correctly for the `getMembersCount` timer (it used to be `getMemberCount`, but the method is callled `getMembersCount` with a plural s). Changes: Call the `getMembersCount` timer from within the `getMembersCount` method itself. Instead of setting that timer up from two different places, we can call it in the method we're timing. This wasn't a problem previously, because the method was only called from a single place. Assuming we always wanna time that query, it makes more sense to put the timing in the actual method.
This commit is contained in:
parent
79c3f8e975
commit
f965246b83
@ -66,7 +66,7 @@ export class ProjectReadModel implements IProjectReadModel {
|
|||||||
query?: IProjectQuery,
|
query?: IProjectQuery,
|
||||||
userId?: number,
|
userId?: number,
|
||||||
): Promise<ProjectForUi[]> {
|
): Promise<ProjectForUi[]> {
|
||||||
const projectTimer = this.timer('getProjectsForProjectList');
|
const projectTimer = this.timer('getProjectsForAdminUi');
|
||||||
let projects = this.db(TABLE)
|
let projects = this.db(TABLE)
|
||||||
.leftJoin('features', 'features.project', 'projects.id')
|
.leftJoin('features', 'features.project', 'projects.id')
|
||||||
.leftJoin(
|
.leftJoin(
|
||||||
@ -129,10 +129,8 @@ export class ProjectReadModel implements IProjectReadModel {
|
|||||||
const projectsWithFeatureCount =
|
const projectsWithFeatureCount =
|
||||||
projectAndFeatureCount.map(mapProjectForUi);
|
projectAndFeatureCount.map(mapProjectForUi);
|
||||||
projectTimer();
|
projectTimer();
|
||||||
const memberTimer = this.timer('getMemberCount');
|
|
||||||
|
|
||||||
const memberCount = await this.getMembersCount();
|
const memberCount = await this.getMembersCount();
|
||||||
memberTimer();
|
|
||||||
const memberMap = new Map<string, number>(
|
const memberMap = new Map<string, number>(
|
||||||
memberCount.map((c) => [c.project, Number(c.count)]),
|
memberCount.map((c) => [c.project, Number(c.count)]),
|
||||||
);
|
);
|
||||||
@ -193,10 +191,8 @@ export class ProjectReadModel implements IProjectReadModel {
|
|||||||
mapProjectForInsights,
|
mapProjectForInsights,
|
||||||
);
|
);
|
||||||
projectTimer();
|
projectTimer();
|
||||||
const memberTimer = this.timer('getMemberCount');
|
|
||||||
|
|
||||||
const memberCount = await this.getMembersCount();
|
const memberCount = await this.getMembersCount();
|
||||||
memberTimer();
|
|
||||||
const memberMap = new Map<string, number>(
|
const memberMap = new Map<string, number>(
|
||||||
memberCount.map((c) => [c.project, Number(c.count)]),
|
memberCount.map((c) => [c.project, Number(c.count)]),
|
||||||
);
|
);
|
||||||
@ -210,6 +206,7 @@ export class ProjectReadModel implements IProjectReadModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getMembersCount(): Promise<IProjectMembersCount[]> {
|
private async getMembersCount(): Promise<IProjectMembersCount[]> {
|
||||||
|
const memberTimer = this.timer('getMembersCount');
|
||||||
const members = await this.db
|
const members = await this.db
|
||||||
.select('project')
|
.select('project')
|
||||||
.from((db) => {
|
.from((db) => {
|
||||||
@ -231,6 +228,8 @@ export class ProjectReadModel implements IProjectReadModel {
|
|||||||
})
|
})
|
||||||
.groupBy('project')
|
.groupBy('project')
|
||||||
.count('user_id');
|
.count('user_id');
|
||||||
|
|
||||||
|
memberTimer();
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user