Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkar598 committed Aug 27, 2023
1 parent b24ba63 commit 1ebf143
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
path: |
.angular/
node_modules
key: ${{ runner.os }}-ng-build-${{ hashFiles('.angular') }}
key: ${{ runner.os }}-ng-build-${{ hashFiles('.angular/') }}
restore-keys: |
${{ runner.os }}-ng-build-
- name: Install dependencies
Expand Down
24 changes: 18 additions & 6 deletions src/app/vote.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,17 @@ export class VoteService {
),
shareReplay(1),
);
rounds$ = combineLatest([this.data$, this.settingsService.seats$]).pipe(
map(([data, seats]) => [data, Math.min(seats, 20000)] as const),
switchMap(([data, total_seats]) => {
if (data === null) return of(null);
rounds$ = combineLatest([
this.data$,
this.settingsService.seats$,
this.sortedCandidates$,
]).pipe(
map(
([data, seats, sortedCandidates]) =>
[data, Math.min(seats, 20000), sortedCandidates] as const,
),
switchMap(([data, total_seats, sortedCandidates]) => {
if (data === null || sortedCandidates === null) return of(null);

const _ballots = data.ballots;
const candidates = data.candidates;
Expand Down Expand Up @@ -210,13 +217,18 @@ export class VoteService {
}

//EliminationReason.TieBreak
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const eliminated = sortedCandidates.find(x =>
lowest_vote.includes(x),
)!;

remaining_candidates = remaining_candidates.filter(
x => x !== lowest_vote[0],
x => x !== eliminated,
);
rounds.push({
...partial_round,
reason: EliminationReason.TieBreak,
eliminated: [lowest_vote[0]],
eliminated: [eliminated],
candidates_remaining: remaining_candidates,
});
}
Expand Down

0 comments on commit 1ebf143

Please sign in to comment.