Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

fix(admin-stats): run stat groups sequentially to bound DB pool usage

Gilad Resisi5b46e8c645af
diff --git a/libraries/nestjs-libraries/src/database/prisma/admin-stats/admin-stats.repository.ts b/libraries/nestjs-libraries/src/database/prisma/admin-stats/admin-stats.repository.ts
index e898f2888..ce548760d 100644
--- a/libraries/nestjs-libraries/src/database/prisma/admin-stats/admin-stats.repository.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/admin-stats/admin-stats.repository.ts
@@ -439,15 +439,18 @@ export class AdminStatsRepository {
async getOrgActivity(
params: OrgActivityParams
): Promise<OrgActivityResponse> {
- const [errors, posts, connectedInRange, channels, postsByState, activity] =
- await Promise.all([
- this.errorStats(params),
- this.postStats(params),
- this.connectedStats(params),
- this.currentChannelStats(params.organizationId, params.includeDeleted),
- this.postStateStats(params),
- this.activityRange(params.organizationId, params.includeDeleted),
- ]);
+ const errors = await this.errorStats(params);
+ const posts = await this.postStats(params);
+ const connectedInRange = await this.connectedStats(params);
+ const channels = await this.currentChannelStats(
+ params.organizationId,
+ params.includeDeleted
+ );
+ const postsByState = await this.postStateStats(params);
+ const activity = await this.activityRange(
+ params.organizationId,
+ params.includeDeleted
+ );
return {
from: params.from.toISOString(),
@@ -463,21 +466,12 @@ export class AdminStatsRepository {
}
async getStats(params: StatsParams): Promise<StatsResponse> {
- const [
- errors,
- posts,
- accounts,
- connected,
- activeOrgsBySource,
- connectedClients,
- ] = await Promise.all([
- this.errorStats(params),
- this.postStats(params),
- this.accountStats(params),
- this.connectedStats(params),
- this.sourceStats(params),
- this.clientStats(params),
- ]);
+ const errors = await this.errorStats(params);
+ const posts = await this.postStats(params);
+ const accounts = await this.accountStats(params);
+ const connected = await this.connectedStats(params);
+ const activeOrgsBySource = await this.sourceStats(params);
+ const connectedClients = await this.clientStats(params);
return {
from: params.from.toISOString(),