Compare commits

..
Author SHA1 Message Date
imcompiling eb5d465ac9 Merge branch 'main' into 49--view-votes-can't-see-HC-elections
build_develop / build (push) Failing after 16s
2024-05-18 22:41:11 -04:00
imcompiling eb1c87fbf4 install sqlite3 onto container. Using it a lot for debugging/fixes.
build_latest / build (push) Successful in 1m29s
build_release / build (push) Successful in 22s
2024-05-18 22:38:57 -04:00
imcompiling cbd73a104e Merge branch '61-Create-virtual-environment-and-update-python-version' 2024-05-18 22:34:35 -04:00
imcompiling bc56830396 Merge branch '49--view-votes-can't-see-HC-elections' of https://gitea.cheezers.org/imcompiling/dakiny-bot into 49--view-votes-can't-see-HC-elections
build_develop / build (push) Failing after 17s
2024-05-18 16:36:03 -04:00
imcompiling 1d14f8171d Add vote type to one statement. 2024-05-18 16:34:33 -04:00
imcompiling 2efd380a7e Add VoteType Enum. 2024-05-18 16:26:11 -04:00
imcompiling 475170025a Edit database to add a type field to Votes. 2024-05-18 16:25:19 -04:00
imcompiling f4f3bfe103 Edit database to add a type field to Votes.
build_develop / build (push) Failing after 18s
2024-05-18 15:39:13 -04:00
4 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
FROM python:3.11.9-slim FROM python:3.11.9-slim
# install dependencies # install dependencies
RUN apt-get update && apt-get -y upgrade && apt-get -y install git RUN apt-get update && apt-get -y upgrade && apt-get -y install git sqlite3
WORKDIR /home WORKDIR /home
+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():
+2 -1
View File
@@ -25,8 +25,9 @@ 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 int unsigned not null,
FOREIGN KEY (ElectionCycle) REFERENCES ElectionInformation(ElectionCycle), FOREIGN KEY (ElectionCycle) REFERENCES ElectionInformation(ElectionCycle),
PRIMARY KEY (ElectionCycle, VoterId) PRIMARY KEY (ElectionCycle, VoterId, Type)
); );
CREATE TABLE UserBirthday ( CREATE TABLE UserBirthday (
+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:
""" """