Use VoteType in election_cycle
This commit is contained in:
@@ -26,9 +26,7 @@ from utils import (
|
|||||||
build_highcouncil_votes_str,
|
build_highcouncil_votes_str,
|
||||||
build_votes_str,
|
build_votes_str,
|
||||||
edit_clan_council_info,
|
edit_clan_council_info,
|
||||||
get_cl_election_name,
|
|
||||||
get_datetime,
|
get_datetime,
|
||||||
get_dm_election_name,
|
|
||||||
get_election_name,
|
get_election_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -298,7 +296,7 @@ class ElectionCycle:
|
|||||||
stmt = (
|
stmt = (
|
||||||
select(Votes.VotedForId)
|
select(Votes.VotedForId)
|
||||||
.where(Votes.ElectionCycle == election_name)
|
.where(Votes.ElectionCycle == election_name)
|
||||||
.where(Votes.Type == VoteType.COUNCIL.value)
|
.where(Votes.Type == VoteType.COUNCIL)
|
||||||
)
|
)
|
||||||
vote_count = collections.Counter(session.scalars(stmt))
|
vote_count = collections.Counter(session.scalars(stmt))
|
||||||
|
|
||||||
@@ -363,11 +361,13 @@ class ElectionCycle:
|
|||||||
self.config.params.clan_council_role_id
|
self.config.params.clan_council_role_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
election_cycle = get_election_name(self.config)
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
# role management
|
# role management
|
||||||
stmt = (
|
stmt = (
|
||||||
select(CouncilMembers.MemberId)
|
select(CouncilMembers.MemberId)
|
||||||
.where(CouncilMembers.ElectionCycle == get_election_name(self.config))
|
.where(CouncilMembers.ElectionCycle == election_cycle)
|
||||||
.where(CouncilMembers.Elected == true())
|
.where(CouncilMembers.Elected == true())
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -384,14 +384,19 @@ class ElectionCycle:
|
|||||||
|
|
||||||
# announce high council members
|
# announce high council members
|
||||||
# ties are undefined behavior.
|
# ties are undefined behavior.
|
||||||
dm_election = get_dm_election_name(self.config)
|
stmt = (
|
||||||
cl_election = get_cl_election_name(self.config)
|
select(Votes.VotedForId)
|
||||||
stmt = select(Votes.VotedForId).where(Votes.ElectionCycle == dm_election)
|
.where(Votes.ElectionCycle == election_cycle)
|
||||||
|
.where(Votes.Type == VoteType.DISCORDMANAGER)
|
||||||
|
)
|
||||||
dm_votes = collections.Counter(session.scalars(stmt))
|
dm_votes = collections.Counter(session.scalars(stmt))
|
||||||
stmt = select(Votes.VotedForId).where(Votes.ElectionCycle == cl_election)
|
stmt = (
|
||||||
|
select(Votes.VotedForId)
|
||||||
|
.where(Votes.ElectionCycle == election_cycle)
|
||||||
|
.where(Votes.Type == VoteType.CLANLEADER)
|
||||||
|
)
|
||||||
cl_votes = collections.Counter(session.scalars(stmt))
|
cl_votes = collections.Counter(session.scalars(stmt))
|
||||||
|
|
||||||
election_cycle = get_election_name(self.config)
|
|
||||||
try:
|
try:
|
||||||
dm_winner = max(dm_votes, key=dm_votes.get)
|
dm_winner = max(dm_votes, key=dm_votes.get)
|
||||||
stmt = (
|
stmt = (
|
||||||
|
|||||||
Reference in New Issue
Block a user