-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'frontend' of github.com:DoodleyJC/RetroOlympics into fr…
…ontend
- Loading branch information
Showing
28 changed files
with
785 additions
and
396 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
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
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
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,53 @@ | ||
name: Node.js CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, labeled, synchronize] | ||
branches: main | ||
|
||
defaults: | ||
run: | ||
working-directory: ./frontend | ||
|
||
jobs: | ||
lint: | ||
if: contains(github.event.pull_request.labels.*.name, 'frontend') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/[email protected] | ||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
package_json_file: "./frontend/package.json" | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: "./frontend/.nvmrc" | ||
cache: pnpm | ||
cache-dependency-path: "./frontend/pnpm-lock.yaml" | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Run lint | ||
run: pnpm lint | ||
build: | ||
if: contains(github.event.pull_request.labels.*.name, 'frontend') | ||
runs-on: ubuntu-latest | ||
needs: [lint] | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/[email protected] | ||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
package_json_file: "./frontend/package.json" | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: "./frontend/.nvmrc" | ||
cache: pnpm | ||
cache-dependency-path: "./frontend/pnpm-lock.yaml" | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Run build | ||
run: pnpm build |
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,30 @@ | ||
name: Python CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, labeled, synchronize] | ||
branches: main | ||
|
||
defaults: | ||
run: | ||
working-directory: ./backend | ||
|
||
jobs: | ||
check-code-quality: | ||
if: contains(github.event.pull_request.labels.*.name, 'backend') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/[email protected] | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
- name: Install dependencies | ||
run: pip install -r requirements-combined.txt | ||
- name: Run lint with ruff | ||
run: ruff . | ||
- name: Check formatting with black | ||
run: black --check . | ||
- name: Check imports with isort | ||
run: isort --check . |
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 |
---|---|---|
|
@@ -20,4 +20,6 @@ build | |
next-env.d.ts | ||
|
||
# Python | ||
*.pyc | ||
*.pyc | ||
|
||
.env |
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
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,3 @@ | ||
from .controller import betting_api | ||
|
||
__all__ = ["betting_api"] |
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,54 @@ | ||
from flask import Blueprint, Response, jsonify, request | ||
|
||
from api.consts import COMMON_API_PREFIX | ||
from api.model.betting import getAll, insertBet | ||
|
||
betting_api = Blueprint( | ||
"betting_api", __name__, url_prefix=COMMON_API_PREFIX + "/betting" | ||
) | ||
|
||
|
||
@betting_api.route("/", methods=["GET"]) | ||
def get_collections(): | ||
try: | ||
responseobject = getAll() | ||
return jsonify(responseobject) | ||
except Exception as e: | ||
print(e) | ||
return Response("something went wrong", 500) | ||
|
||
|
||
@betting_api.route("/", methods=["POST", "PUT"]) | ||
def handle_post(): | ||
if request.method == "POST": | ||
try: | ||
content = request.json | ||
userid = content["userid"] | ||
matchid = content["matchid"] | ||
teamid = content["teamid"] | ||
amount = content["amount"] | ||
except Exception as e: | ||
print(e) | ||
return Response( | ||
"""content_type="bad request, please supply the following: \"user\", \"matchid\", \"teamid\"and \"amount\" | ||
in json form with a content-type json header""", | ||
400, | ||
) | ||
try: | ||
print( | ||
f"userid = {userid}, matchid={matchid}, teamid{teamid}, amount={amount}" | ||
) | ||
insertBet(userid, matchid, teamid, amount) | ||
return Response("inserted", 200) | ||
except Exception as e: | ||
print(e) | ||
return Response( | ||
"""something went wrong with inserting the bet in the database""", 500 | ||
) | ||
else: | ||
return Response("Only posts are allowed right now", 400) | ||
|
||
|
||
@betting_api.route("/datatest", methods=["GET", "POST", "PUT"]) | ||
def handle_test(): | ||
pass |
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
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,28 @@ | ||
import psycopg2 | ||
|
||
from .main import datacon, getAll, insertBet, removeBet | ||
|
||
__all__ = ["insertBet", "removeBet", "getAll"] | ||
|
||
|
||
createTableString = """ | ||
CREATE TABLE bettingtest ( | ||
id SERIAL PRIMARY KEY, | ||
userid VARCHAR, | ||
matchid INT, | ||
teamid INT, | ||
amount FLOAT | ||
); | ||
""" | ||
|
||
|
||
def __init__(): | ||
with datacon.cursor() as curs: | ||
try: | ||
curs.execute(createTableString) | ||
except psycopg2.errors.DuplicateTable: | ||
print("duplicate table encountered") | ||
pass | ||
|
||
|
||
__init__() |
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,26 @@ | ||
from api.model.database import bettingconn as datacon | ||
|
||
datacon.autocommit = True | ||
|
||
|
||
def insertBet(userid, matchid, teamid, amount): | ||
with datacon.cursor() as curs: | ||
curs.execute( | ||
f"""INSERT INTO bettingtest (userid, matchid, teamid, amount) | ||
VALUES ({userid},{matchid},{teamid},{amount});""" | ||
) | ||
|
||
|
||
def getAll(): | ||
with datacon.cursor() as curs: | ||
curs.execute( | ||
""" | ||
SELECT * FROM bettingtest; | ||
""" | ||
) | ||
res = curs.fetchall() | ||
return res | ||
|
||
|
||
def removeBet(): | ||
pass |
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,3 @@ | ||
from .main import bettingconn | ||
|
||
__all__ = ["bettingconn"] |
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,6 @@ | ||
import psycopg2 | ||
|
||
bettingconn = psycopg2.connect( | ||
host="db", user="postgres", password="postgres", dbname="retroolympics" | ||
) | ||
bettingconn.autocommit = 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
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 +1,2 @@ | ||
Flask==3.0.3 | ||
Flask==3.0.3 | ||
Psycopg2==2.9.9 |
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
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
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,3 @@ | ||
.next | ||
pnpm-lock.yaml | ||
public |
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,4 @@ | ||
{ | ||
"printWidth": 120, | ||
"plugins": ["prettier-plugin-tailwindcss"] | ||
} |
Oops, something went wrong.