Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Meeting Info: change count structure levels #4450

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand All @@ -15,6 +18,7 @@ import { ViewListOfSpeakers, ViewSpeaker } from '../view-models';
export interface SpeakingTimeStructureLevelObject {
finishedSpeakers: ViewSpeaker[];
speakingTime: number;
name: string;
}

@Injectable({
Expand All @@ -23,7 +27,8 @@ export interface SpeakingTimeStructureLevelObject {
export class ListOfSpeakersControllerService extends BaseController<ViewListOfSpeakers, ListOfSpeakers> {
public constructor(
controllerServiceCollector: ControllerServiceCollectorService,
protected override repo: ListOfSpeakersRepositoryService
protected override repo: ListOfSpeakersRepositoryService,
private meetingSettings: MeetingSettingsService
) {
super(controllerServiceCollector, ListOfSpeakers, repo);
}
Expand Down Expand Up @@ -58,48 +63,46 @@ export class ListOfSpeakersControllerService extends BaseController<ViewListOfSp
* @returns A list, which entries are `SpeakingTimeStructureLevelObject`.
*/
public getSpeakingTimeStructureLevelRelation(): SpeakingTimeStructureLevelObject[] {
let listSpeakingTimeStructureLevel: SpeakingTimeStructureLevelObject[] = [];
const mapForAggregation = new Map<Id, SpeakingTimeStructureLevelObject>();
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 structureLevelOrNull = speaker.structure_level_list_of_speakers?.structure_level;
this.putIntoMapForAggregation(structureLevelOrNull, speaker, mapForAggregation);
} else {
for (const structureLevel of speaker.user?.structure_levels() ?? []) {
this.putIntoMapForAggregation(structureLevel, speaker, mapForAggregation);
}
if (!(speaker.user?.structure_levels() ?? []).length) {
this.putIntoMapForAggregation(null, speaker, mapForAggregation);
}
}
}
}
return listSpeakingTimeStructureLevel;
return Array.from(mapForAggregation.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 | null,
speaker: ViewSpeaker,
mapForAggregation: Map<Id, SpeakingTimeStructureLevelObject>
): void {
let structureLevelId = -1;
if (!!structureLevel) {
structureLevelId = structureLevel.id;
}
if (mapForAggregation.has(structureLevelId)) {
const entry = mapForAggregation.get(structureLevelId);
entry.finishedSpeakers.push(speaker);
entry.speakingTime += this.getSpeakingTimeAsNumber(speaker);
} else {
mapForAggregation.set(structureLevelId, {
finishedSpeakers: [speaker],
speakingTime: this.getSpeakingTimeAsNumber(speaker),
name: structureLevelId === -1 ? `Without Structure Level` : structureLevel.name
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -49,14 +50,45 @@ 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: [],
follow: [
{
idField: `speaker_ids`,
fieldset: [`begin_time`, `end_time`, `point_of_order`],
follow: [`meeting_user_id`]
follow: [
{
idField: `meeting_user_id`,
fieldset: [`user_id`],
follow: [
{
idField: `structure_level_ids`,
fieldset: [`name`]
}
]
},
{
idField: `structure_level_list_of_speakers_id`,
fieldset: FULL_FIELDSET,
follow: [
{
idField: `structure_level_id`,
fieldset: [`name`]
}
]
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<!-- Content -->
<div *osScrollingTableCell="'structureLevel'; row as object" class="ellipsis-overflow">
<div *osScrollingTableCellLabel>{{ 'Structure level' | translate }}</div>
{{ object.structureLevel | translate }}
{{ object.name }}
</div>
<div *osScrollingTableCell="'durationOfWordRequests'; row as object; config: { width: '100px' }">
<div *osScrollingTableCellLabel>{{ 'Duration of requests to speak' | translate }}</div>
Expand Down
Loading