Skip to content

Commit 1d7b9e7

Browse files
committed
feat: add limit parameter to activity totals queries and remove console logs
1 parent 866972f commit 1d7b9e7

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

backend/src/services/seats.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,11 @@ class SeatsService {
441441
org?: string;
442442
since?: string;
443443
until?: string;
444+
limit?: number;
444445
}) {
445446
const ActivityTotals = mongoose.model('ActivityTotals');
446447
const { org, since, until } = params;
448+
const limit = typeof params.limit === 'string' ? parseInt(params.limit) : (params.limit || 100);
447449

448450
const match: mongoose.FilterQuery<MemberActivityType> = {};
449451
if (org) match.org = org;
@@ -472,6 +474,7 @@ class SeatsService {
472474
}
473475
},
474476
{ $sort: { total_time: -1 } },
477+
{ $limit: limit },
475478
{
476479
$project: {
477480
_id: 0,

frontend/src/app/main/copilot/copilot-metrics/copilot-metrics.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ export class CopilotMetricsComponent implements OnInit {
8888
this.subscriptions.push(
8989
this.seatService.getActivityTotals({
9090
org: this.installation?.account?.login,
91-
since: startModified.toISOString(),
92-
until: endModified.toISOString()
91+
since: event.start.toISOString(),
92+
until: event.end.toISOString(),
93+
limit: 10
9394
}).subscribe(totals => {
94-
Object.keys(totals).forEach((key, index) => index > 10 ? delete totals[key] : null);
9595
this.activityTotals = totals;
9696
this.cdr.detectChanges();
9797
})

frontend/src/app/services/api/seat.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class SeatService {
7575
org?: string | undefined;
7676
since?: string;
7777
until?: string;
78+
limit?: number;
7879
}) {
7980
if (!queryParams?.org) delete queryParams?.org;
8081
return this.http.get<Record<string, number>>(`${this.apiUrl}/activity/totals`, {

0 commit comments

Comments
 (0)