Skip to content

Commit 846ca80

Browse files
Mutugiiidogi
andauthored
manager: smoother reports voices added (fixes #8758) (#8759)
Co-authored-by: dogi <[email protected]>
1 parent dc62af7 commit 846ca80

File tree

5 files changed

+51
-20
lines changed

5 files changed

+51
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "planet",
33
"license": "AGPL-3.0",
4-
"version": "0.19.16",
4+
"version": "0.19.17",
55
"myplanet": {
66
"latest": "v0.25.74",
77
"min": "v0.24.74"

src/app/manager-dashboard/reports/reports-detail.component.html

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
<canvas id="courseViewChart"></canvas>
163163
<canvas id="stepCompletedChart"></canvas>
164164
<canvas id="chatUsageChart"></canvas>
165+
<canvas id="voicesCreatedChart"></canvas>
165166
<div class="reports-table-container">
166167
<div>
167168
<h1 class="mat-title" i18n>Members</h1>
@@ -277,10 +278,10 @@ <h1 class="mat-title" i18n>Courses</h1>
277278
No data found
278279
</div>
279280
<div *ngIf="!resourcesLoading && resourceActivities?.byDoc && resourceActivities.byDoc.length > 0">
280-
<planet-reports-detail-activities
281-
[activitiesByDoc]="resourceActivities.byDoc"
282-
[ratings]="ratings.resources"
283-
activityType="resources"
281+
<planet-reports-detail-activities
282+
[activitiesByDoc]="resourceActivities.byDoc"
283+
[ratings]="ratings.resources"
284+
activityType="resources"
284285
(itemClick)="openResourceView($event)">
285286
</planet-reports-detail-activities>
286287
</div>
@@ -293,11 +294,11 @@ <h1 class="mat-title" i18n>Courses</h1>
293294
No data found
294295
</div>
295296
<div *ngIf="!coursesLoading && courseActivities?.byDoc && courseActivities.byDoc.length > 0">
296-
<planet-reports-detail-activities
297-
[activitiesByDoc]="courseActivities.byDoc"
298-
[ratings]="ratings.courses"
299-
[progress]="progress"
300-
activityType="courses"
297+
<planet-reports-detail-activities
298+
[activitiesByDoc]="courseActivities.byDoc"
299+
[ratings]="ratings.courses"
300+
[progress]="progress"
301+
activityType="courses"
301302
(itemClick)="openCourseView($event)">
302303
</planet-reports-detail-activities>
303304
</div>
@@ -310,10 +311,10 @@ <h1 class="mat-title" i18n>Courses</h1>
310311
No data found
311312
</div>
312313
<div [hidden]="healthLoading || healthNoData">
313-
<planet-reports-health
314-
[planetCode]="planetCode"
315-
[dateRange]="dateFilterForm?.value"
316-
[isActive]="healthTab.isActive"
314+
<planet-reports-health
315+
[planetCode]="planetCode"
316+
[dateRange]="dateFilterForm?.value"
317+
[isActive]="healthTab.isActive"
317318
(changeDateRange)="resetDateFilter($event)"
318319
(healthLoadingChange)="onHealthLoadingChange($event)"
319320
(healthNoDataChange)="onHealthNoDataChange($event)">
@@ -328,8 +329,8 @@ <h1 class="mat-title" i18n>Courses</h1>
328329
No data found
329330
</div>
330331
<div *ngIf="!chatLoading && chatActivities?.filteredData && chatActivities.filteredData.length > 0">
331-
<planet-reports-detail-activities
332-
[activitiesByDoc]="chatActivities.filteredData"
332+
<planet-reports-detail-activities
333+
[activitiesByDoc]="chatActivities.filteredData"
333334
activityType="chat">
334335
</planet-reports-detail-activities>
335336
</div>

src/app/manager-dashboard/reports/reports-detail.component.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class ReportsDetailComponent implements OnInit, OnDestroy {
5656
steps: new ReportsDetailData('time')
5757
};
5858
chatActivities = new ReportsDetailData('createdDate');
59+
voicesActivities = new ReportsDetailData('time');
5960
today: Date;
6061
minDate: Date;
6162
ratings = { total: new ReportsDetailData('time'), resources: [], courses: [] };
@@ -75,6 +76,7 @@ export class ReportsDetailComponent implements OnInit, OnDestroy {
7576
coursesLoading = true;
7677
chatLoading = true;
7778
healthLoading = true;
79+
voicesLoading = true;
7880
healthNoData = false;
7981
timeFilterOptions = this.activityService.standardTimeFilters;
8082

@@ -170,6 +172,7 @@ export class ReportsDetailComponent implements OnInit, OnDestroy {
170172
this.getPlanetCounts(local);
171173
this.getTeams();
172174
this.getChatUsage();
175+
this.getVoicesUsage();
173176
this.dialogsLoadingService.stop();
174177
});
175178
}
@@ -233,6 +236,8 @@ export class ReportsDetailComponent implements OnInit, OnDestroy {
233236
));
234237
this.chatActivities.filter(this.filter);
235238
this.setChatUsage();
239+
this.voicesActivities.filter(this.filter);
240+
this.setVoicesUsage();
236241
}
237242

238243
getLoginActivities() {
@@ -380,6 +385,21 @@ export class ReportsDetailComponent implements OnInit, OnDestroy {
380385
this.setChart({ ...this.setGenderDatasets(byMonth), chartName: 'chatUsageChart' });
381386
}
382387

388+
getVoicesUsage() {
389+
this.activityService.getVoicesCreated().subscribe((data) => {
390+
this.voicesActivities.data = data.map(item => ({
391+
...item,
392+
user: item.user?.name || '',
393+
}));
394+
this.voicesLoading = false;
395+
});
396+
}
397+
398+
setVoicesUsage() {
399+
const { byMonth } = this.activityService.groupVoicesCreated(this.voicesActivities.filteredData);
400+
this.setChart({ ...this.setGenderDatasets(byMonth), chartName: 'voicesCreatedChart' });
401+
}
402+
383403
getTeamMembers(team: any) {
384404
if (team === 'All') {
385405
return of([]);

src/app/manager-dashboard/reports/reports.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,7 @@ export class ReportsService {
273273

274274
getChatHistory() {
275275
return this.couchService.get('chat_history/_all_docs', { params: { include_docs: 'true' } })
276-
.pipe(
277-
map((data: any) => data.rows.map((row: any) => row.doc))
278-
);
276+
.pipe(map((data: any) => data.rows.map((row: any) => row.doc)));
279277
}
280278

281279
groupChatUsage(chats: any) {
@@ -284,6 +282,17 @@ export class ReportsService {
284282
});
285283
}
286284

285+
getVoicesCreated() {
286+
return this.couchService.get('news/_all_docs', { params: { include_docs: 'true' } })
287+
.pipe(map((data: any) => data.rows.map((row: any) => row.doc)));
288+
}
289+
290+
groupVoicesCreated(voices: any[]) {
291+
return ({
292+
byMonth: this.groupByMonth(this.appendGender(voices), 'time', '_id')
293+
});
294+
}
295+
287296
groupStepCompletion(steps: any[]) {
288297
return ({
289298
byMonth: this.groupByMonth(this.appendGender(steps), 'time', 'userId')

src/app/manager-dashboard/reports/reports.utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export const titleOfChartName = (chartName: string) => {
101101
visitChart: $localize`Total Member Visits by Month`,
102102
uniqueVisitChart: $localize`Unique Member Visits by Month`,
103103
stepCompletedChart: $localize`Steps Completed by Month`,
104-
chatUsageChart: $localize`Chats Created by Month`
104+
chatUsageChart: $localize`Chats Created by Month`,
105+
voicesCreatedChart: $localize`Voices Created by Month`,
105106
};
106107
return chartNames[chartName];
107108
};

0 commit comments

Comments
 (0)