Skip to content

Commit

Permalink
Fix: for duplicate candidates
Browse files Browse the repository at this point in the history
The same candidate was found to be in the download two times with the same filer_id. This caused the database insert to fail.
The candidates added to the database will now have unique filer_id fields.
  • Loading branch information
robertgz committed Mar 23, 2024
1 parent 476c862 commit 2014c4b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/update-command/src/efile.api/candidates.update.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ export class CandidatesUpdateService {
(candidate) => candidate.jurisdiction_code.toUpperCase() === 'CIT',
);

if (filteredClasses.length > 0) {
await this.candidateAddService.addCandidate(filteredClasses);
// Remove classes with duplicate "filer_id" fields
const uniqueClasses = [
...new Map(
filteredClasses.map((item) => [item['filer_id'], item]),
).values(),
];

if (uniqueClasses.length > 0) {
await this.candidateAddService.addCandidate(uniqueClasses);
}

const generalClasses = await this.getCandidatesClasses(
Expand Down

0 comments on commit 2014c4b

Please sign in to comment.