Change ElectionCycle class to Election. Change ElectionCycle column in database to ElectionName. Update some variables for clarification.
This commit is contained in:
@@ -41,14 +41,14 @@ class VoteSelect(nextcord.ui.StringSelect):
|
||||
election_name: str = get_election_name(self.config)
|
||||
with Session(engine) as session:
|
||||
stmt = select(ElectionInformation.HighCouncilVoteMsgId).where(
|
||||
ElectionInformation.ElectionCycle == election_name
|
||||
ElectionInformation.ElectionName == election_name
|
||||
)
|
||||
vote_msg_id = session.scalar(stmt)
|
||||
|
||||
voted_for = None if self.values[0] == "Abstain" else int(self.values[0])
|
||||
|
||||
new_vote = Votes(
|
||||
ElectionCycle=election_name,
|
||||
ElectionName=election_name,
|
||||
VoterId=interaction.user.id,
|
||||
VotedForId=voted_for,
|
||||
Type=self.election_type,
|
||||
@@ -63,7 +63,7 @@ class VoteSelect(nextcord.ui.StringSelect):
|
||||
session.rollback()
|
||||
stmt = (
|
||||
update(Votes)
|
||||
.where(Votes.ElectionCycle == election_name)
|
||||
.where(Votes.ElectionName == election_name)
|
||||
.where(Votes.VoterId == interaction.user.id)
|
||||
.where(Votes.Type == self.election_type)
|
||||
.values(VotedForId=voted_for)
|
||||
@@ -118,7 +118,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
with Session(engine) as session:
|
||||
stmt = (
|
||||
select(Votes.VotedForId)
|
||||
.where(Votes.ElectionCycle == election_name)
|
||||
.where(Votes.ElectionName == election_name)
|
||||
.where(Votes.VoterId == interaction.user.id)
|
||||
.where(Votes.Type == VoteType.CLANLEADER)
|
||||
)
|
||||
@@ -126,7 +126,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
|
||||
stmt = (
|
||||
select(CouncilMembers.MemberId)
|
||||
.where(CouncilMembers.ElectionCycle == election_name)
|
||||
.where(CouncilMembers.ElectionName == election_name)
|
||||
.filter(CouncilMembers.ClanLeaderSpeechId.is_not(None))
|
||||
)
|
||||
|
||||
@@ -190,7 +190,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
with Session(engine) as session:
|
||||
stmt = (
|
||||
select(Votes.VotedForId)
|
||||
.where(Votes.ElectionCycle == election_name)
|
||||
.where(Votes.ElectionName == election_name)
|
||||
.where(Votes.VoterId == interaction.user.id)
|
||||
.where(Votes.Type == VoteType.DISCORDMANAGER)
|
||||
)
|
||||
@@ -198,7 +198,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
|
||||
stmt = (
|
||||
select(CouncilMembers.MemberId)
|
||||
.where(CouncilMembers.ElectionCycle == election_name)
|
||||
.where(CouncilMembers.ElectionName == election_name)
|
||||
.filter(CouncilMembers.DiscordManagerSpeechId.is_not(None))
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user