Compare commits

..
5 Commits
Author SHA1 Message Date
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
7 changed files with 26 additions and 29 deletions
-1
View File
@@ -105,7 +105,6 @@ venv/
ENV/ ENV/
env.bak/ env.bak/
venv.bak/ venv.bak/
poetry.lock
# Spyder project settings # Spyder project settings
.spyderproject .spyderproject
+7 -4
View File
@@ -1,19 +1,22 @@
FROM python:3.11.9-slim FROM python:3.10.6-slim
# install dependencies # install dependencies
RUN apt-get update && apt-get -y upgrade && apt-get -y install git sqlite3 RUN apt-get update && apt-get -y upgrade && apt-get -y install git
RUN pip install --upgrade pip
WORKDIR /home WORKDIR /home
COPY requirements.txt requirements.txt
COPY config.py config.py COPY config.py config.py
COPY main.py main.py COPY main.py main.py
COPY utils.py utils.py COPY utils.py utils.py
COPY pyproject.toml pyproject.toml
COPY classes classes/ COPY classes classes/
COPY cogs cogs/ COPY cogs cogs/
COPY database_setup database_setup/ COPY database_setup database_setup/
RUN pip install --upgrade pip && pip install poetry && poetry export -f requirements.txt --output requirements.txt && pip install -r requirements.txt RUN pip install -r requirements.txt
CMD ["python3", "-u", "./main.py"] CMD ["python3", "-u", "./main.py"]
+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 (
-22
View File
@@ -1,22 +0,0 @@
[tool.poetry]
name = "dakiny-bot"
version = "0.1.0"
description = "Dakiny's Discord Bot."
authors = ["imcompiling <[email protected]>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
gitpython = "3.1.43"
fastapi = "0.111.0"
hydra-core = "1.3.2"
nextcord = "2.4.2"
pandas = "1.5.2"
python-dotenv = "1.0.0"
pytz = "2022.7.1"
sqlalchemy = "1.4.46"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
+8
View File
@@ -0,0 +1,8 @@
GitPython==3.1.43
fastapi==0.111.0
hydra-core==1.3.2
nextcord==2.4.2
pandas==1.5.2
python-dotenv==1.0.0
pytz==2022.7.1
sqlalchemy==1.4.46
+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:
""" """