You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO this may be inefficient with large number of users
import{Participant,Poll,PollEvent,StatisticsDto}from'@apollusia/types';import{Injectable}from'@nestjs/common';import{InjectModel}from'@nestjs/mongoose';import{Model}from'mongoose';
@Injectable()exportclassStatisticsService{constructor(
@InjectModel(Poll.name)privatepollModel: Model<Poll>,
@InjectModel(PollEvent.name)privatepollEventModel: Model<PollEvent>,
@InjectModel(Participant.name)privateparticipantModel: Model<Participant>,){}asyncgetStats(): Promise<StatisticsDto>{const[polls,pollEvents,participants,pollTokens,participantTokens,]=awaitPromise.all([this.pollModel.countDocuments().exec(),this.pollEventModel.countDocuments().exec(),this.participantModel.countDocuments().exec(),this.pollModel.distinct('token').exec(),this.participantModel.distinct('token').exec(),]);return{
polls,
pollEvents,
participants,// TODO this may be inefficient with large number of usersusers: newSet([...pollTokens, ...participantTokens]).size,};}}
The text was updated successfully, but these errors were encountered:
apollusia/apps/backend/src/statistics/statistics/statistics.service.ts
Line 33 in 43fd16f
The text was updated successfully, but these errors were encountered: