Skip to content

Commit

Permalink
Merge pull request #9 from DISIC/dev
Browse files Browse the repository at this point in the history
fix(pencil): refactoring du code, fix de l'envoi de stats
  • Loading branch information
HamzaKhait authored Mar 27, 2024
2 parents 7a01258 + 1d62cc9 commit 698e306
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/authentication/authentication.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class AuthenticationController {

@Get('whereami')
whereami(@Headers('webconf-user-region') userAgent: string) {
console.log(userAgent);
return userAgent;
}

Expand Down
16 changes: 11 additions & 5 deletions src/prosody/prosody.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export class ProsodyService {
private readonly httpService: HttpService,
) {}

private jicofo_available_instances: string[] = this.configService.get(
'JICOFO_AVAILABLE_INSTANCES',
)
? this.configService.get('JICOFO_AVAILABLE_INSTANCES').split(' ')
: [];

private prosody_available_instances: string[] = this.configService.get(
'PROSODY_AVAILABLE_INSTANCES',
)
Expand Down Expand Up @@ -38,7 +44,7 @@ export class ProsodyService {
? this.prosody_available_instances.map(
(url) =>
url +
`/room?domain=${prosody_domain}&room=${roomName}&subdomain=`,
`/room?domain=${prosody_domain}&room=${roomName.toLocaleLowerCase()}&subdomain=`,
)
: null;

Expand Down Expand Up @@ -69,9 +75,9 @@ export class ProsodyService {

async getRealTimeStats() {
const stats_prosody_urls =
this.prosody_available_instances.length !== 0 &&
this.prosody_available_instances.map((url) => {
return this.httpService.axiosRef.get(url + '/nbConfPart');
this.jicofo_available_instances.length !== 0 &&
this.jicofo_available_instances.map((url) => {
return this.httpService.axiosRef.get(url + '/stats');
});

try {
Expand All @@ -80,7 +86,7 @@ export class ProsodyService {
res.forEach((element) => data.push(element.data));
return data;
} catch (error) {
throw new NotFoundException("le serveur prosody n'est pas disponible");
throw new NotFoundException("le serveur jicofo n'est pas disponible");
}
}
}
4 changes: 2 additions & 2 deletions src/stats/stats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export class StatsService {
if (data.length > 1) {
const mergedData = { conf: 0, part: 0 };
for (let i = 0; i < data.length; i++) {
mergedData.conf += data[i].conf;
mergedData.part += data[i].part;
mergedData.conf += data[i].conferences;
mergedData.part += data[i].participants;
}
return mergedData;
} else {
Expand Down

0 comments on commit 698e306

Please sign in to comment.