Pull the vote count message out of vote start.

Make its own builder function in utils.
This commit is contained in:
2023-11-03 11:55:21 -04:00
parent a5ef579767
commit fa3284b9e3
3 changed files with 40 additions and 27 deletions
-22
View File
@@ -122,33 +122,11 @@ class ElectionCycle:
message = file.read()
vote_end: datetime = get_datetime(self.config.election_cycles[self.cycle].voting_end)
votes: dict[int, int] = {}
with Session(engine) as session:
stmt = select(CouncilMembers).where(ElectionCycle == get_election_cycle_name(self.config))
for nominee in session.scalars(stmt):
votes[nominee.MemberId] = 0
stmt = select(Votes).where(ElectionCycle == get_election_cycle_name(self.config))
for vote in session.scalars(stmt):
votes[vote.VotedForId] += 1
nominees_str: str = ""
for user_id, num_votes in votes.items():
nominees_str += f"<@{user_id}>: "
for num in range(num_votes):
nominees_str += "☑️"
nominees_str += "\n"
return message.format(
clan_member_id=self.config.params.clan_member_role_id,
voting_emote_id=self.config.params.voting_emote_id,
voting_end=vote_end.strftime("%B %d"),
voting_end_day=vote_end.strftime("%A"),
clan_nominees=nominees_str,
)
async def check_date(self) -> None: