Compare commits

..
4 Commits
3 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -22,6 +22,7 @@ from database_setup.sql_data_classes import (
) )
from utils import ( from utils import (
TEMPLATES_DIR, TEMPLATES_DIR,
VoteType,
build_highcouncil_votes_str, build_highcouncil_votes_str,
build_votes_str, build_votes_str,
edit_clan_council_info, edit_clan_council_info,
@@ -294,7 +295,11 @@ class ElectionCycle:
session.commit() session.commit()
# add the highcouncil role to everyone with 3 or more votes. set elected to true in database # add the highcouncil role to everyone with 3 or more votes. set elected to true in database
stmt = select(Votes.VotedForId).where(Votes.ElectionCycle == election_name) stmt = (
select(Votes.VotedForId)
.where(Votes.ElectionCycle == election_name)
.where(Votes.Type == VoteType.COUNCIL.value)
)
vote_count = collections.Counter(session.scalars(stmt)) vote_count = collections.Counter(session.scalars(stmt))
for user_id, votes in vote_count.items(): for user_id, votes in vote_count.items():
+1 -1
View File
@@ -25,7 +25,7 @@ CREATE TABLE Votes(
ElectionCycle varchar(30) not null, ElectionCycle varchar(30) not null,
VoterId bigint unsigned not null, VoterId bigint unsigned not null,
VotedForId bigint unsigned, VotedForId bigint unsigned,
Type varchar(14) check("Type" in ('Council','DiscordManager','ClanLeader')), Type int unsigned not null,
FOREIGN KEY (ElectionCycle) REFERENCES ElectionInformation(ElectionCycle), FOREIGN KEY (ElectionCycle) REFERENCES ElectionInformation(ElectionCycle),
PRIMARY KEY (ElectionCycle, VoterId, Type) PRIMARY KEY (ElectionCycle, VoterId, Type)
); );
+3
View File
@@ -4,6 +4,7 @@ File contains util functions.
import os import os
from datetime import datetime from datetime import datetime
from enum import Enum
from typing import Iterable from typing import Iterable
import nextcord import nextcord
@@ -24,6 +25,8 @@ REPO_DIR = "./dakiny-messages"
MESSAGES_DIR = f"{REPO_DIR}/messages" MESSAGES_DIR = f"{REPO_DIR}/messages"
TEMPLATES_DIR = f"{REPO_DIR}/message_templates" TEMPLATES_DIR = f"{REPO_DIR}/message_templates"
VoteType = Enum("VoteType", ["COUNCIL", "DISCORDMANAGER", "CLANLEADER"])
def get_datetime(day: str) -> datetime: def get_datetime(day: str) -> datetime:
""" """