From cf7ee615e6d191fdf6488496e900d687c3bb4e77 Mon Sep 17 00:00:00 2001 From: "Outrun Colors, LLC" Date: Sat, 28 May 2022 19:02:35 -0500 Subject: [PATCH] Add skeleton for route interactions --- files/routes/lottery.py | 31 +++++++++++++++++++++++++++++- files/templates/lottery_modal.html | 2 -- lottery.sql | 30 +++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 lottery.sql diff --git a/files/routes/lottery.py b/files/routes/lottery.py index 7ef7923b14..281069bec4 100644 --- a/files/routes/lottery.py +++ b/files/routes/lottery.py @@ -4,6 +4,25 @@ from files.helpers.alerts import * from files.helpers.get import * from files.helpers.const import * + +@app.post("/lottery/start") +@auth_required +def lottery_start(v): + # Save changes + g.db.commit() + + return {"message": "Lottershe started."} + + +@app.post("/lottery/end") +@auth_required +def lottery_end(v): + # Save changes + g.db.commit() + + return {"message": "Lottershe ended."} + + @app.post("/lottery/buy") @limiter.limit("1/second;30/minute;200/hour;1000/day") @auth_required @@ -14,7 +33,17 @@ def lottery_buy(v): # Charge user for ticket v.coins -= 12 + # Check for active lottery + pass + # Save changes g.db.commit() - return {"message": "Lottershe ticket purchased!"} + return {"message": "Lottershe ticket purchased!", "stats": {"sessionEnds": 0, "prize": 0, "ticketsSoldSession": 0, "ticketsSoldTotal": 0, "ticketsHeldSession": 0, "ticketsHeldTotal": 0, "totalWinnings": 0}} + + +@app.get("/lottery/stats") +@limiter.limit("1/second;30/minute;200/hour;1000/day") +@auth_required +def lottery_stats(v): + return {"message": {"sessionEnds": 0, "prize": 0, "ticketsSoldSession": 0, "ticketsSoldTotal": 0}} diff --git a/files/templates/lottery_modal.html b/files/templates/lottery_modal.html index b0183d65f1..89d6726ca7 100644 --- a/files/templates/lottery_modal.html +++ b/files/templates/lottery_modal.html @@ -29,7 +29,6 @@
Grand Prize
Session Ends
-
Unique Participants
Tickets Sold (Session)
Tickets Sold (Total)
@@ -38,7 +37,6 @@
0:00:00
0
0
-
0
diff --git a/lottery.sql b/lottery.sql new file mode 100644 index 0000000000..6c5597c091 --- /dev/null +++ b/lottery.sql @@ -0,0 +1,30 @@ +CREATE TABLE public.lotteries ( + id integer NOT NULL, + is_active boolean DEFAULT false NOT NULL, + ends_at timestamptz NOT NULL, + prize integer DEFAULT 0 NOT NULL, + tickets_sold integer DEFAULT 0 NOT NULL +); + +-- +-- Name: lotteries_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.lotteries_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +-- +-- Name: lotteries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.lotteries_id_seq OWNED BY public.lotteries.id; + +ALTER TABLE public.users + ADD currently_held_lottery_tickets integer DEFAULT 0 NOT NULL, + ADD total_held_lottery_tickets integer DEFAULT 0 NOT NULL, + ADD total_lottery_winnings integer DEFAULT 0 NOT NULL; \ No newline at end of file