|
@@ -48,6 +48,10 @@ import {
|
|
|
ElectedCouncil,
|
|
|
CastVote,
|
|
|
CandidacyNoteMetadata,
|
|
|
+ CandidacyStatusActive,
|
|
|
+ CandidacyStatusWithdrawn,
|
|
|
+ CandidacyStatusElected,
|
|
|
+ CandidacyStatusLost,
|
|
|
|
|
|
// Misc
|
|
|
Membership,
|
|
@@ -387,7 +391,7 @@ export async function council_NewCandidate({ event, store }: EventContext & Stor
|
|
|
stakingAccountId: stakingAccount.toString(),
|
|
|
rewardAccountId: rewardAccount.toString(),
|
|
|
member,
|
|
|
-
|
|
|
+ status: new CandidacyStatusActive(),
|
|
|
electionRound,
|
|
|
stake: balance,
|
|
|
stakeLocked: true,
|
|
@@ -433,11 +437,15 @@ export async function council_NewCouncilElected({ event, store }: EventContext &
|
|
|
// get election round and its candidates
|
|
|
const electionRound = await getCurrentElectionRound(store)
|
|
|
|
|
|
- // TODO: uncomment when following query will be working (after some QN patches make it to Olympia)
|
|
|
- // const electedCandidates = await store.getMany(Candidate, { where: { electionRoundId: electionRound.id, member: { id_in: electedMemberIds } } })
|
|
|
- const electedCandidates = (
|
|
|
- await store.getMany(Candidate, { where: { electionRoundId: electionRound.id }, relations: ['member'] })
|
|
|
- ).filter((item: Candidate) => electedMemberIds.find((tmpId) => tmpId === item.member.id.toString()))
|
|
|
+ const where = { electionRoundId: electionRound.id, status_json: { isTypeOf_eq: 'CandidacyStatusActive' } }
|
|
|
+ const candidates = await store.getMany(Candidate, { where })
|
|
|
+
|
|
|
+ const electedCandidates = candidates.filter((candidate) => electedMemberIds.includes(candidate.member.id))
|
|
|
+
|
|
|
+ // Set candidates elected status
|
|
|
+ electedCandidates.forEach((candidate) => {
|
|
|
+ candidate.status = new CandidacyStatusElected()
|
|
|
+ })
|
|
|
|
|
|
// create new council record
|
|
|
const electedCouncil = new ElectedCouncil({
|
|
@@ -561,6 +569,7 @@ export async function council_CandidacyWithdraw({ event, store }: EventContext &
|
|
|
|
|
|
// mark candidacy as withdrawn
|
|
|
candidate.candidacyWithdrawn = true
|
|
|
+ candidate.status = new CandidacyStatusWithdrawn()
|
|
|
await store.save<Candidate>(candidate)
|
|
|
}
|
|
|
|