-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
79 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
__pycache__ | ||
.vscode | ||
.ruff_cache | ||
.env | ||
token | ||
token | ||
postgres/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
services: | ||
stan: | ||
build: | ||
context: service | ||
dockerfile: Dockerfile | ||
depends_on: | ||
- postgres | ||
networks: | ||
- default | ||
- db | ||
env_file: | ||
- .env | ||
postgres: | ||
image: postgres:16-alpine | ||
volumes: | ||
- ./postgres:/var/lib/postgresql/data | ||
networks: | ||
- db | ||
env_file: | ||
- .env | ||
nginx: | ||
image: nginx:alpine | ||
ports: | ||
- 80:80 | ||
volumes: | ||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf | ||
depends_on: | ||
- stan | ||
networks: | ||
- default | ||
restart: always | ||
|
||
networks: | ||
default: | ||
db: | ||
internal: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
|
||
server_name _; | ||
|
||
# api proxy | ||
location /api { | ||
proxy_pass http://stan:8080; | ||
} | ||
|
||
# static files | ||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM python:3.12-alpine | ||
|
||
WORKDIR /opt/stan | ||
|
||
ENTRYPOINT [ "python", "main.py" ] | ||
|
||
EXPOSE 8080 | ||
COPY . /opt/stan | ||
RUN pip3 install --no-cache-dir -r requirements.txt |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
__email__ = "[email protected]" | ||
|
||
import logging | ||
import os | ||
from dataclasses import asdict | ||
import dataset # type: ignore | ||
from common.singleton import Singleton | ||
|
@@ -14,9 +15,10 @@ | |
VERIFIED_USERS_TABLE = "Verified_Users" | ||
HSLU_STUDENTS_TABLE = "HSLU_Students" | ||
|
||
DB_USERNAME = "postgres" | ||
DB_PASSWORD = "postgres" | ||
DB_HOST = "localhost:5432" | ||
DB_USERNAME = os.getenv("POSTGRES_USER") | ||
DB_PASSWORD = os.getenv("POSTGRES_PASSWORD") | ||
DB_DATABASE = os.getenv("POSTGRES_DB") | ||
DB_HOST = "postgres:5432" | ||
DB_PROTOCOL = "postgresql" | ||
|
||
|
||
|
@@ -25,7 +27,7 @@ class Database(metaclass=Singleton): | |
|
||
def __init__(self) -> None: | ||
self._db = dataset.connect( | ||
f"{DB_PROTOCOL}://{DB_USERNAME}:{DB_PASSWORD}@{DB_HOST}/" | ||
f"{DB_PROTOCOL}://{DB_USERNAME}:{DB_PASSWORD}@{DB_HOST}/{DB_DATABASE}" | ||
) | ||
self._logger = logging.getLogger("Database") | ||
|
||
|
@@ -49,9 +51,7 @@ def update_students( | |
""" | ||
current_members = self.all_verified() | ||
previous_students = [x for x in current_members if x.state == UserState.STUDENT] | ||
previous_graduates = [ | ||
x for x in current_members if x.state == UserState.GRADUATE | ||
] | ||
previous_graduates = [x for x in current_members if x.state == UserState.GRADUATE] | ||
|
||
self._hslu_students_table.drop() | ||
# make unique | ||
|
@@ -104,9 +104,5 @@ def all_verified(self) -> list[VerifiedUser]: | |
def verify_member(self, discord_id: int, email: str) -> None: | ||
"""Verify a member by their Discord ID and email.""" | ||
self._users_table.insert( | ||
asdict( | ||
VerifiedUser( | ||
discord_id=discord_id, email=email, state=UserState.STUDENT | ||
) | ||
) | ||
asdict(VerifiedUser(discord_id=discord_id, email=email, state=UserState.STUDENT)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
0
lint.sh → service/lint.sh
100755 → 100644
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
dataset==1.6.2 | ||
aiohttp==3.9.5 | ||
discord.py==2.3.2 | ||
psycopg2==2.9.9 | ||
psycopg2-binary==2.9.9 | ||
pyaddict==1.0.7 | ||
uvloop==0.19.0 | ||
python-dotenv==1.0.1 | ||
msal==1.28.0 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.