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 (
TEMPLATES_DIR,
VoteType,
build_highcouncil_votes_str,
build_votes_str,
edit_clan_council_info,
@@ -294,7 +295,11 @@ class ElectionCycle:
session.commit()
# 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))
for user_id, votes in vote_count.items():
+1 -1
View File
@@ -25,7 +25,7 @@ CREATE TABLE Votes(
ElectionCycle varchar(30) not null,
VoterId bigint unsigned not null,
VotedForId bigint unsigned,
Type varchar(14) check("Type" in ('Council','DiscordManager','ClanLeader')),
Type int unsigned not null,
FOREIGN KEY (ElectionCycle) REFERENCES ElectionInformation(ElectionCycle),
PRIMARY KEY (ElectionCycle, VoterId, Type)
);
+3
View File
@@ -4,6 +4,7 @@ File contains util functions.
import os
from datetime import datetime
from enum import Enum
from typing import Iterable
import nextcord
@@ -24,6 +25,8 @@ REPO_DIR = "./dakiny-messages"
MESSAGES_DIR = f"{REPO_DIR}/messages"
TEMPLATES_DIR = f"{REPO_DIR}/message_templates"
VoteType = Enum("VoteType", ["COUNCIL", "DISCORDMANAGER", "CLANLEADER"])
def get_datetime(day: str) -> datetime:
"""