Skip to content

Commit

Permalink
Database + Crud Backend (#24)
Browse files Browse the repository at this point in the history
* feat: created DB file

* feat: type model for scouting system

* chore: update svelte

* feat: tried

* feat: nothing

* feat: add none

* feat: added DB.sql and migrations

* refactor: type state model

* feat: state transforms

* add successfail screen

* theme fixes

* fix: package.json

* fix: formating

* fix: dependencies

* format thingy

* feat: implemented submit api

* fix: removed unnecessary line

* refactor: update types to match new schema

* fix: id after clarifying with Brandon

* update dep

* style: format files

* feat: pulled from main

* style: format files

* fix: dependencies

* style: format files

* fix: dependencies

* fix: skill property name

* fix: removed npm config

* fix: bun dependencies

* feat: finished submit function

* feat: read route

* feat: superscouting and pit scouting in db

* fix: DB code

* fix: updated queries to allow ids

* fix: tailwind to CommonJS module

* style: format files

* fix: queries

* style: format files

* fix: types

* style: format files

* feat: hooked up frontend to backend

* fix: queries

* feat: functional queries

* style: format files

* fix: queries returning too much

* more merge

---------

Co-authored-by: Brandon Harad <[email protected]>
Co-authored-by: awwpotato <[email protected]>
Co-authored-by: awwpotato <[email protected]>
Co-authored-by: Brandon-Harad <[email protected]>
Co-authored-by: azaleacolburn <[email protected]>
  • Loading branch information
6 people authored Dec 11, 2024
1 parent 1ee1ac7 commit 8db5a09
Show file tree
Hide file tree
Showing 11 changed files with 532 additions and 59 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DB_HOST = "0"
DB_USER = "0"
DB_PASSWORD = "0"
POSTGRES_DATABASE = "0"
USE_DB = "false"
DB_PORT = "0"
Binary file modified bun.lockb
Binary file not shown.
171 changes: 171 additions & 0 deletions migrations/DB.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
CREATE TYPE tele_action_type AS ENUM (
'IntakeTote',
'IntakeBalloon',
'TakeBalloonFromCoral',

'ScoreYourHeldTote',
'ScoreOtherHeldTote',
'ScoreExternalTote',
'ScoreLowBalloon'
);
CREATE TYPE auto_action_type as ENUM (
'IntakeTote',
'IntakeBalloon',
'TakeBalloonFromCoral',

'ScoreYourHeldTote',
'ScoreOtherHeldTote',
'ScoreExternalTote',
'ScoreLowBalloon',

'IntakeBunny',
'ScoreBunnyTote',
'ScoreBunnyLowZone'
);
CREATE TYPE tele_action_data AS (
act tele_action_type,
success BOOLEAN
);
CREATE TYPE auto_action_data AS (
act auto_action_type,
success BOOLEAN
);
CREATE TYPE drivetrain_enum as ENUM (
'Swerve',
'Tank',
'Other'
);

CREATE TABLE "Users"(
"id" SERIAL PRIMARY KEY,
"name" VARCHAR(255) NOT NULL,
"is_admin" BOOLEAN NOT NULL
);
CREATE TABLE "Teams"(
"team_key" VARCHAR(255) NOT NULL,
"nickname" VARCHAR(255) NOT NULL
);
ALTER TABLE
"Teams" ADD PRIMARY KEY("team_key");
CREATE TABLE "Matches"(
"match_key" VARCHAR(255) NOT NULL,
"event_key" VARCHAR(255) NOT NULL
);
ALTER TABLE
"Matches" ADD PRIMARY KEY("match_key");
CREATE TABLE "TeamMatches"(
"id" SERIAL PRIMARY KEY,
"scout_id" VARCHAR(255) NOT NULL,
"match_key" VARCHAR(255) NOT NULL,
"team_key" VARCHAR(255) NOT NULL,
"skill_field_awareness" SMALLINT NOT NULL,
"skill_quickness" SMALLINT NOT NULL,
"notes" VARCHAR(255) NOT NULL,
"broke" BOOLEAN NOT NULL,
"died" BOOLEAN NOT NULL,
"tele_action_id" SMALLINT NOT NULL,
"auto_action_id" SMALLINT NOT NULL
);
CREATE TABLE "TeleActions"(
"id" SERIAL PRIMARY KEY,
"tote_intake_success" SMALLINT NOT NULL,
"tote_intake_failure" SMALLINT NOT NULL,
"tote_eject_success" SMALLINT NOT NULL,
"tote_eject_failure" SMALLINT NOT NULL,
"balloon_intake_success" SMALLINT NOT NULL,
"balloon_intake_failure" SMALLINT NOT NULL,
"balloon_eject_success" SMALLINT NOT NULL,
"balloon_eject_failure" SMALLINT NOT NULL,
"score_low_success" SMALLINT NOT NULL,
"score_low_failure" SMALLINT NOT NULL,
"score_internal_success" SMALLINT NOT NULL,
"score_internal_failure" SMALLINT NOT NULL,
"score_external_success" SMALLINT NOT NULL,
"score_external_failure" SMALLINT NOT NULL,
"score_uncontrolled_success" SMALLINT NOT NULL,
"score_uncontrolled_failure" SMALLINT NOT NULL,
"bunny_eject_success" SMALLINT NOT NULL,
"bunny_eject_failure" SMALLINT NOT NULL,
"actions" tele_action_data[]
);
CREATE TABLE "AutoActions"(
"id" SERIAL PRIMARY KEY,
"tote_intake_success" SMALLINT NOT NULL,
"tote_intake_failure" SMALLINT NOT NULL,
"tote_eject_success" SMALLINT NOT NULL,
"tote_eject_failure" SMALLINT NOT NULL,
"balloon_intake_success" SMALLINT NOT NULL,
"balloon_intake_failure" SMALLINT NOT NULL,
"balloon_eject_success" SMALLINT NOT NULL,
"balloon_eject_failure" SMALLINT NOT NULL,
"score_low_success" SMALLINT NOT NULL,
"score_low_failure" SMALLINT NOT NULL,
"score_internal_sucess" SMALLINT NOT NULL,
"score_internal_failure" SMALLINT NOT NULL,
"score_external_success" SMALLINT NOT NULL,
"score_external_failure" SMALLINT NOT NULL,
"score_uncontrolled_success" SMALLINT NOT NULL,
"score_uncontrolled_failure" SMALLINT NOT NULL,
"bunny_intake_success" SMALLINT NOT NULL,
"bunny_intake_failure" SMALLINT NOT NULL,
"bunny_eject_success" SMALLINT NOT NULL,
"bunny_eject_failure" SMALLINT NOT NULL,
"bunny_internal_success" SMALLINT NOT NULL,
"bunny_internal_failure" SMALLINT NOT NULL,
"bunny_external_success" SMALLINT NOT NULL,
"bunny_external_failure" SMALLINT NOT NULL,
"bunny_uncontrolled_success" SMALLINT NOT NULL,
"bunny_uncontrolled_failure" SMALLINT NOT NULL,
"bunny_low_success" SMALLINT NOT NULL,
"bunny_low_failure" SMALLINT NOT NULL,
"actions" auto_action_data[]
);
CREATE TABLE "AllianceMatches"(
"id" SERIAL PRIMARY KEY,
"scout_id" VARCHAR(255) NOT NULL,
"match_key" VARCHAR(255) NOT NULL,
"alliance_key" VARCHAR(255) NOT NULL,
"one_strengths" VARCHAR(255) NOT NULL,
"two_strengths" VARCHAR(255) NOT NULL,
"three_strengths" VARCHAR(255) NOT NULL,
"one_weaknesses" VARCHAR(255) NOT NULL,
"two_weaknesses" VARCHAR(255) NOT NULL,
"three_weaknesses" VARCHAR(255) NOT NULL,
"notes" VARCHAR(255) NOT NULL,
"match_notes" VARCHAR(255) NOT NULL
);
CREATE TABLE "TeamEvents"(
"id" SERIAL PRIMARY KEY,
"scout_id" VARCHAR(255) NOT NULL,
"team_key" VARCHAR(255) NOT NULL,
"width" SMALLINT NOT NULL,
"length" SMALLINT NOT NULL,
"height" SMALLINT NOT NULL,
"is_camera" BOOLEAN NOT NULL,
"drivetrain_enum" drivetrain_enum NOT NULL,
"is_slippery" BOOLEAN NOT NULL,
"is_tote_intake" BOOLEAN NOT NULL,
"is_balloon_intake" BOOLEAN NOT NULL,
"number_bunny_autos" SMALLINT NOT NULL,
"polish" SMALLINT NOT NULL,
"robot_notes" VARCHAR(255) NOT NULL,
"minibot_notes" VARCHAR(255) NOT NULL
);
-- ALTER TABLE
-- "TeamEvents" ADD CONSTRAINT "teamevents_scout_id_foreign" FOREIGN KEY("scout_id") REFERENCES "Users"("id");
-- ALTER TABLE
-- "AllianceMatches" ADD CONSTRAINT "alliancematches_match_key_foreign" FOREIGN KEY("match_key") REFERENCES "Matches"("match_key");
-- ALTER TABLE
-- "TeamMatches" ADD CONSTRAINT "teammatches_team_key_foreign" FOREIGN KEY("team_key") REFERENCES "Teams"("team_key");
-- ALTER TABLE
-- "TeamMatches" ADD CONSTRAINT "teammatches_match_key_foreign" FOREIGN KEY("match_key") REFERENCES "Matches"("match_key");
-- ALTER TABLE
-- "TeamMatches" ADD CONSTRAINT "teammatches_scout_id_foreign" FOREIGN KEY("scout_id") REFERENCES "Users"("id");
-- ALTER TABLE
-- "TeamMatches" ADD CONSTRAINT "teammatches_auto_id_foreign" FOREIGN KEY("auto_action_id") REFERENCES "AutoActions"("id");
-- ALTER TABLE
-- "TeamEvents" ADD CONSTRAINT "teamevents_team_key_foreign" FOREIGN KEY("team_key") REFERENCES "Teams"("team_key");
-- ALTER TABLE
-- "TeamMatches" ADD CONSTRAINT "teammatches_tele_id_foreign" FOREIGN KEY("tele_action_id") REFERENCES "TeleActions"("id");
-- ALTER TABLE
-- "AllianceMatches" ADD CONSTRAINT "alliancematches_scout_id_foreign" FOREIGN KEY("scout_id") REFERENCES "Users"("id");
39 changes: 24 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,34 @@
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.3.1",
"@sveltejs/kit": "^2.9.0",
"@sveltejs/vite-plugin-svelte": "^4.0.2",
"@sveltejs/kit": "^2.8.1",
"@types/node": "^22.9.0",
"@types/pg": "^8.11.10",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@types/eslint": "^9.6.1",
"autoprefixer": "^10.4.20",
"eslint": "^9.16.0",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.46.1",
"globals": "^15.13.0",
"prettier": "^3.4.1",
"prettier-plugin-svelte": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.9",
"svelte": "^5.5.2",
"svelte-check": "^4.1.1",
"tailwindcss": "^3.4.16",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"vite": "^5.4.11"
"eslint-plugin-svelte": "^2.46.0",
"postcss": "^8.4.49",
"globals": "^15.12.0",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.8",
"svelte": "^5.1.16",
"svelte-check": "^4.0.7",
"tslib": "^2.8.1",
"prettier-plugin-tailwindcss": "^0.6.8",
"typescript": "^5.6.3"
},
"dependencies": {
"autoprefixer": "^10.4.20",
"mysql2": "^3.11.4",
"pg": "^8.13.1",
"postgresql": "^0.0.1",
"tailwindcss": "^3.4.14",
"typescript-eslint": "^8.14.0",
"vite": "^5.4.11",
"lucide-svelte": "^0.460.1",
"socket.io": "^4.8.1",
"socket.io-client": "^4.8.1"
Expand Down
Loading

0 comments on commit 8db5a09

Please sign in to comment.