Add nominees and voting total to voting message.
This commit is contained in:
@@ -11,4 +11,8 @@ After a candidate receives 3 votes, their spot is secured in the new council, bu
|
|||||||
Votes for multiple candidates from the same person will not be counted.
|
Votes for multiple candidates from the same person will not be counted.
|
||||||
|
|
||||||
RS3 Clan Members
|
RS3 Clan Members
|
||||||
OSRS Clan Members
|
OSRS Clan Members
|
||||||
|
|
||||||
|
====================
|
||||||
|
Clan nominees:
|
||||||
|
{clan_nominees}
|
||||||
@@ -10,7 +10,7 @@ from sqlalchemy.orm import Session
|
|||||||
|
|
||||||
from classes.nominate_views import NominateView
|
from classes.nominate_views import NominateView
|
||||||
from config import DakinyConfig
|
from config import DakinyConfig
|
||||||
from database_setup.sql_data_classes import ElectionInformation, engine
|
from database_setup.sql_data_classes import CouncilMembers, ElectionInformation, Votes, engine
|
||||||
from utils import get_datetime, get_election_cycle_name
|
from utils import get_datetime, get_election_cycle_name
|
||||||
|
|
||||||
|
|
||||||
@@ -121,11 +121,33 @@ class ElectionCycle:
|
|||||||
message = file.read()
|
message = file.read()
|
||||||
vote_end: datetime = get_datetime(self.config.election_cycles[self.cycle].voting_end)
|
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(
|
return message.format(
|
||||||
clan_member_id=self.config.params.clan_member_role_id,
|
clan_member_id=self.config.params.clan_member_role_id,
|
||||||
voting_emote_id=self.config.params.voting_emote_id,
|
voting_emote_id=self.config.params.voting_emote_id,
|
||||||
voting_end=vote_end.strftime("%B %d"),
|
voting_end=vote_end.strftime("%B %d"),
|
||||||
voting_end_day=vote_end.strftime("%A"),
|
voting_end_day=vote_end.strftime("%A"),
|
||||||
|
clan_nominees=nominees_str,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def check_date(self) -> None:
|
async def check_date(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user