From 6eb968c40b42a61381a88a574ca3e143f1c02fa6 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Wed, 4 Dec 2024 10:57:49 +0100 Subject: [PATCH 1/5] Update Meeting Info: change count structure levels --- .../list-of-speakers-controller.service.ts | 73 +++++++++---------- .../meeting-info/meeting-info.component.ts | 28 ++++++- .../user-statistics.component.html | 2 +- 3 files changed, 64 insertions(+), 39 deletions(-) diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts index cc04631af2..a09dfabf3e 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts @@ -1,10 +1,13 @@ import { Injectable } from '@angular/core'; +import { Id } from 'src/app/domain/definitions/key-types'; import { ListOfSpeakers } from 'src/app/domain/models/list-of-speakers/list-of-speakers'; import { ListOfSpeakersRepositoryService } from 'src/app/gateways/repositories/list-of-speakers/list-of-speakers-repository.service'; import { BaseController } from 'src/app/site/base/base-controller'; import { BaseViewModel } from 'src/app/site/base/base-view-model'; +import { MeetingSettingsService } from 'src/app/site/pages/meetings/services/meeting-settings.service'; import { ControllerServiceCollectorService } from 'src/app/site/services/controller-service-collector.service'; +import { ViewStructureLevel } from '../../../../participants/pages/structure-levels/view-models'; import { ViewListOfSpeakers, ViewSpeaker } from '../view-models'; /** @@ -15,6 +18,7 @@ import { ViewListOfSpeakers, ViewSpeaker } from '../view-models'; export interface SpeakingTimeStructureLevelObject { finishedSpeakers: ViewSpeaker[]; speakingTime: number; + name: string; } @Injectable({ @@ -23,7 +27,8 @@ export interface SpeakingTimeStructureLevelObject { export class ListOfSpeakersControllerService extends BaseController { public constructor( controllerServiceCollector: ControllerServiceCollectorService, - protected override repo: ListOfSpeakersRepositoryService + protected override repo: ListOfSpeakersRepositoryService, + private meetingSettings: MeetingSettingsService ) { super(controllerServiceCollector, ListOfSpeakers, repo); } @@ -58,48 +63,42 @@ export class ListOfSpeakersControllerService extends BaseController(); + const parliamentMode = this.meetingSettings.instant(`list_of_speakers_default_structure_level_time`); for (const los of this.getViewModelList()) { for (const speaker of los.finishedSpeakers) { - const nextEntry = this.getSpeakingTimeStructureLevelObject(speaker); - listSpeakingTimeStructureLevel = this.getSpeakingTimeStructureLevelList( - nextEntry, - listSpeakingTimeStructureLevel - ); + if (!!parliamentMode) { + const structureLevel = speaker.structure_level_list_of_speakers?.structure_level; + if (!!structureLevel) { + this.putIntoMapForAggregation(structureLevel, speaker, map_for_aggregation); + } + } else { + for (const structureLevel of speaker.user.structure_levels()) { + this.putIntoMapForAggregation(structureLevel, speaker, map_for_aggregation); + } + } } } - return listSpeakingTimeStructureLevel; + return Array.from(map_for_aggregation.values()); } - /** - * Helper-function to create a `SpeakingTimeStructureLevelObject` by a given speaker. - * - * @param speaker, with whom structure-level and speaking-time is calculated. - * - * @returns The created `SpeakingTimeStructureLevelObject`. - */ - private getSpeakingTimeStructureLevelObject(speaker: ViewSpeaker): SpeakingTimeStructureLevelObject { - return { - finishedSpeakers: [speaker], - speakingTime: this.getSpeakingTimeAsNumber(speaker) - }; - } - - /** - * Helper-function to update entries in a given list, if already existing, or create entries otherwise. - * - * @param object A `SpeakingTimeStructureLevelObject`, that contains information about speaking-time - * and structure-level. - * @param list A list, at which speaking-time, structure-level and finished_speakers are set. - * - * @returns The updated map. - */ - private getSpeakingTimeStructureLevelList( - object: SpeakingTimeStructureLevelObject, - list: SpeakingTimeStructureLevelObject[] - ): SpeakingTimeStructureLevelObject[] { - list.push(object); - return list; + private putIntoMapForAggregation( + structureLevel: ViewStructureLevel, + speaker: ViewSpeaker, + map_for_aggregation: Map + ): void { + const structureLevelId = structureLevel.id; + if (map_for_aggregation.has(structureLevelId)) { + const entry = map_for_aggregation.get(structureLevelId); + entry.finishedSpeakers.push(speaker); + entry.speakingTime += this.getSpeakingTimeAsNumber(speaker); + } else { + map_for_aggregation.set(structureLevelId, { + finishedSpeakers: [speaker], + speakingTime: this.getSpeakingTimeAsNumber(speaker), + name: structureLevel.name + }); + } } /** diff --git a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts index 008f029a5f..adb5a8c93a 100644 --- a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts +++ b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { filter, firstValueFrom, map } from 'rxjs'; +import { FULL_FIELDSET } from 'src/app/domain/fieldsets/misc'; import { OrganizationRepositoryService } from 'src/app/gateways/repositories/organization-repository.service'; import { BaseMeetingComponent } from 'src/app/site/pages/meetings/base/base-meeting.component'; import { ViewMeeting } from 'src/app/site/pages/meetings/view-models/view-meeting'; @@ -49,6 +50,16 @@ export class MeetingInfoComponent extends BaseMeetingComponent implements OnInit } ] }, + { + idField: `speaker_ids`, + fieldset: [`id`, `begin_time`, `end_time`], + follow: [ + { + idField: `structure_level_list_of_speakers_id`, + fieldset: FULL_FIELDSET + } + ] + }, { idField: `list_of_speakers_ids`, fieldset: [], @@ -56,7 +67,22 @@ export class MeetingInfoComponent extends BaseMeetingComponent implements OnInit { idField: `speaker_ids`, fieldset: [`begin_time`, `end_time`, `point_of_order`], - follow: [`meeting_user_id`] + follow: [ + { + idField: `meeting_user_id`, + fieldset: FULL_FIELDSET + }, + { + idField: `structure_level_list_of_speakers_id`, + fieldset: FULL_FIELDSET, + follow: [ + { + idField: `structure_level_id`, + fieldset: [`name`] + } + ] + } + ] } ] } diff --git a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/user-statistics/user-statistics.component.html b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/user-statistics/user-statistics.component.html index 3a0d8d884e..cb08140136 100644 --- a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/user-statistics/user-statistics.component.html +++ b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/user-statistics/user-statistics.component.html @@ -37,7 +37,7 @@
{{ 'Structure level' | translate }}
- {{ object.structureLevel | translate }} + {{ object.name }}
{{ 'Duration of requests to speak' | translate }}
From 94c942567ca5af1d2d1d1910ed22d05a66eefeb1 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Thu, 5 Dec 2024 14:57:37 +0100 Subject: [PATCH 2/5] Add 'Without structure level' for parliamentMode --- .../list-of-speakers-controller.service.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts index a09dfabf3e..6b74020be5 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts @@ -68,10 +68,8 @@ export class ListOfSpeakersControllerService extends BaseController ): void { - const structureLevelId = structureLevel.id; + let structureLevelId = -1; + if (!!structureLevel) { + structureLevelId = structureLevel.id; + } if (map_for_aggregation.has(structureLevelId)) { const entry = map_for_aggregation.get(structureLevelId); entry.finishedSpeakers.push(speaker); @@ -96,7 +97,7 @@ export class ListOfSpeakersControllerService extends BaseController Date: Mon, 9 Dec 2024 12:50:17 +0100 Subject: [PATCH 3/5] Rename map_for_aggregation, update subscription --- .../list-of-speakers-controller.service.ts | 16 ++++++++-------- .../meeting-info/meeting-info.component.ts | 5 +---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts index 6b74020be5..5c1f2df1bb 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts @@ -63,38 +63,38 @@ export class ListOfSpeakersControllerService extends BaseController(); + const mapForAggregation = new Map(); const parliamentMode = this.meetingSettings.instant(`list_of_speakers_default_structure_level_time`); for (const los of this.getViewModelList()) { for (const speaker of los.finishedSpeakers) { if (!!parliamentMode) { const structureLevelOrNull = speaker.structure_level_list_of_speakers?.structure_level; - this.putIntoMapForAggregation(structureLevelOrNull, speaker, map_for_aggregation); + this.putIntoMapForAggregation(structureLevelOrNull, speaker, mapForAggregation); } else { for (const structureLevel of speaker.user.structure_levels()) { - this.putIntoMapForAggregation(structureLevel, speaker, map_for_aggregation); + this.putIntoMapForAggregation(structureLevel, speaker, mapForAggregation); } } } } - return Array.from(map_for_aggregation.values()); + return Array.from(mapForAggregation.values()); } private putIntoMapForAggregation( structureLevel: ViewStructureLevel | null, speaker: ViewSpeaker, - map_for_aggregation: Map + mapForAggregation: Map ): void { let structureLevelId = -1; if (!!structureLevel) { structureLevelId = structureLevel.id; } - if (map_for_aggregation.has(structureLevelId)) { - const entry = map_for_aggregation.get(structureLevelId); + if (mapForAggregation.has(structureLevelId)) { + const entry = mapForAggregation.get(structureLevelId); entry.finishedSpeakers.push(speaker); entry.speakingTime += this.getSpeakingTimeAsNumber(speaker); } else { - map_for_aggregation.set(structureLevelId, { + mapForAggregation.set(structureLevelId, { finishedSpeakers: [speaker], speakingTime: this.getSpeakingTimeAsNumber(speaker), name: structureLevelId === -1 ? `Without Structure Level` : structureLevel.name diff --git a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts index adb5a8c93a..d45a93b14d 100644 --- a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts +++ b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts @@ -68,10 +68,7 @@ export class MeetingInfoComponent extends BaseMeetingComponent implements OnInit idField: `speaker_ids`, fieldset: [`begin_time`, `end_time`, `point_of_order`], follow: [ - { - idField: `meeting_user_id`, - fieldset: FULL_FIELDSET - }, + `meeting_user_id`, { idField: `structure_level_list_of_speakers_id`, fieldset: FULL_FIELDSET, From 8336291755f364161f1abe9538d42acc400e15fc Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Mon, 9 Dec 2024 13:42:40 +0100 Subject: [PATCH 4/5] Update meeting info subscription, small fix The autoupdate service needs some time to return the meeting_info_X subscription result. In this interval speaker.user is undefined. --- .../services/list-of-speakers-controller.service.ts | 2 +- .../components/meeting-info/meeting-info.component.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts index 5c1f2df1bb..3e319b0af2 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts @@ -71,7 +71,7 @@ export class ListOfSpeakersControllerService extends BaseController Date: Mon, 16 Dec 2024 11:41:00 +0100 Subject: [PATCH 5/5] Add two fixes to non-parliament mode (sub, empty strlvl) --- .../services/list-of-speakers-controller.service.ts | 3 +++ .../components/meeting-info/meeting-info.component.ts | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts index 3e319b0af2..e3c4ac1d0d 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts @@ -74,6 +74,9 @@ export class ListOfSpeakersControllerService extends BaseController