Skip to content

Commit

Permalink
add index for general mandate
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnlaugurG committed Sep 25, 2024
1 parent 1890e27 commit 616902d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,8 @@ export class DelegationAdminCustomService {
},
)

// Index custom delegations for the toNationalId
void this.delegationIndexService.indexCustomDelegations(
delegation.toNationalId,
)
// Index delegations for the toNationalId
void this.indexDelegations(delegation.toNationalId)

return newDelegation.toDTO(AuthDelegationType.GeneralMandate)
}
Expand Down Expand Up @@ -243,10 +241,8 @@ export class DelegationAdminCustomService {
})
}

// Index custom delegations for the toNationalId
void this.delegationIndexService.indexCustomDelegations(
delegation.toNationalId,
)
// Index delegations for the toNationalId
void this.indexDelegations(delegation.toNationalId)
})
}

Expand All @@ -268,4 +264,9 @@ export class DelegationAdminCustomService {
)
}
}

private indexDelegations(nationalId: string) {
void this.delegationIndexService.indexCustomDelegations(nationalId)
void this.delegationIndexService.indexGeneralMandateDelegations(nationalId)
}
}
19 changes: 19 additions & 0 deletions libs/auth-api-lib/src/lib/delegations/delegations-index.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ export class DelegationsIndexService {
await this.saveToIndex(nationalId, delegations)
}

/* Index incoming general mandate delegations */
async indexGeneralMandateDelegations(nationalId: string) {
const delegations = await this.getGeneralMandateDelegation(nationalId, true)
await this.saveToIndex(nationalId, delegations)
}

/* Index incoming personal representative delegations */
async indexRepresentativeDelegations(nationalId: string) {
const delegations = await this.getRepresentativeDelegations(
Expand Down Expand Up @@ -483,6 +489,19 @@ export class DelegationsIndexService {
)
}

private async getGeneralMandateDelegation(
nationalId: string,
useMaster = false,
) {
const delegation =
await this.delegationsIncomingCustomService.findAllValidGeneralMandate(
{ nationalId },
useMaster,
)

return delegation.map(toDelegationIndexInfo)
}

private async getCustomDelegations(nationalId: string, useMaster = false) {
const delegations =
await this.delegationsIncomingCustomService.findAllValidIncoming(
Expand Down

0 comments on commit 616902d

Please sign in to comment.