Skip to content

Commit

Permalink
Fix grouped voter names
Browse files Browse the repository at this point in the history
  • Loading branch information
moorscode committed Feb 13, 2021
1 parent 92b8343 commit daab68d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backend/src/pokers/pokers.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { OnGatewayInit, SubscribeMessage, WebSocketGateway, WebSocketServer } fr
import { Server, Socket } from "socket.io";
import { PointsService } from "../points/points.service";
import { Member, Story, Vote, VoteValue } from "./poker-room";
import { PokersService, MemberGroups, GroupVoteName } from "./pokers.service";
import { PokersService, MemberGroups, GroupVoteNames } from "./pokers.service";

interface VoteResponse {
voterName: string;
Expand All @@ -13,7 +13,7 @@ interface VoteResponse {
interface VotesResponse {
votes: VoteResponse[];
voteCount: number;
groupedVoterNames: GroupVoteName[];
groupedVoterNames: GroupVoteNames;
votedNames: string[];
voteAverage?: number | string;
nearestPointAverage?: VoteValue;
Expand Down
8 changes: 4 additions & 4 deletions backend/src/pokers/pokers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { Socket } from "socket.io";
import { PointsService } from "../points/points.service";
import { Member, PokerRoom, Story, Vote } from "./poker-room";

export interface GroupVoteName {
export interface GroupVoteNames {
[ group: string ]: string[];
}

interface CurrentVotes {
voteCount: number;
votes: Vote[];
groupedVoterNames: GroupVoteName[];
groupedVoterNames: GroupVoteNames;
}

export interface Rooms {
Expand Down Expand Up @@ -285,13 +285,13 @@ export class PokersService {
const room: PokerRoom = this.getRoom( poker );
const voted: Member[] = room.getVotedClients();
const votes = room.getCurrentVotes();
const groupedVoterNames: GroupVoteName[] = voted.reduce( ( accumulator, member: Member ) => {
const groupedVoterNames: GroupVoteNames = voted.reduce( ( accumulator, member: Member ) => {
const vote = room.getCurrentVote( member.id );
const voteGroupKey: string = vote.initialValue + "/" + vote.currentValue;
accumulator[ voteGroupKey ] = accumulator[ voteGroupKey ] || [];
accumulator[ voteGroupKey ].push( member.name );
return accumulator;
}, [] );
}, {} );

return {
voteCount: voted.length,
Expand Down

0 comments on commit daab68d

Please sign in to comment.