Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"start": "node dist/src/server.js --omit=dev",
"test": "tsc",
"lint": "eslint .",
"format": "prettier --write ."
"format": "prettier --write .",
"import-all-matches": "tsx src/runImportAllTournaments.ts"
},
"keywords": [],
"author": "",
Expand Down
282 changes: 250 additions & 32 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generator client {
provider = "prisma-client-js"
engineType = "binary"
provider = "prisma-client-js"
engineType = "binary"
}

datasource db {
Expand All @@ -26,14 +26,108 @@ model FeatureToggle {
enabled Boolean @default(true)
}

model TeamMatchData {
key String @id
model Match {
key String @id
tournamentKey String
matchNumber Int @db.SmallInt
teamNumber Int
matchType MatchType
scoutReports ScoutReport[]
tournament Tournament @relation(fields: [tournamentKey], references: [key], onDelete: Cascade)
year Int
compLevel MatchType
setNumber Int
matchNumber Int
scheduledTime DateTime?
actualTime DateTime?
redScore Int?
blueScore Int?
rawTba String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

tournament Tournament @relation(fields: [tournamentKey], references: [key], onDelete: Cascade)
participants MatchParticipant[]
breakdowns OfficialAllianceBreakdown[]
videos MatchVideo[]

@@index([tournamentKey, compLevel, matchNumber])
}

model MatchParticipant {
matchKey String
teamNumber Int
alliance AllianceColor
station Int
teamMatchKey String? @unique

match Match @relation(fields: [matchKey], references: [key], onDelete: Cascade)
teamMatchData TeamMatchData? @relation(fields: [teamMatchKey], references: [key])

@@id([matchKey, teamNumber])
@@index([teamNumber])
}

model OfficialAllianceBreakdown {
matchKey String
alliance AllianceColor

isConsistent Boolean?
raw Json
fetchedAt DateTime @default(now())
updatedAt DateTime @updatedAt

match Match @relation(fields: [matchKey], references: [key], onDelete: Cascade)

@@id([matchKey, alliance])
}

model ReefscapeAllianceBreakdowns {
matchKey String
alliance AllianceColor
match Match @relation(fields: [matchKey], references: [key], onDelete: Cascade)

autoCoralCount Int?
autoCoralPoints Int?
teleopCoralCount Int?
teleopCoralPoints Int?

autoL1 Int?
autoL2 Int?
autoL3 Int?
autoL4 Int?

teleopL1 Int?
teleopL2 Int?
teleopL3 Int?
teleopL4 Int?


@@id([matchKey, alliance])
}

model MatchVideo {
uuid String @id @default(uuid())
matchKey String
type String
externalKey String
createdAt DateTime @default(now())

match Match @relation(fields: [matchKey], references: [key], onDelete: Cascade)

@@unique([matchKey, type, externalKey])
@@index([matchKey])
}

enum AllianceColor {
RED
BLUE
}

model TeamMatchData {
key String @id
tournamentKey String
matchNumber Int @db.SmallInt
teamNumber Int
matchType MatchType
scoutReports ScoutReport[]
matchParticipant MatchParticipant?
tournament Tournament @relation(fields: [tournamentKey], references: [key], onDelete: Cascade)

@@index([tournamentKey, teamNumber])
}
Expand Down Expand Up @@ -62,6 +156,23 @@ model ScoutReport {
teamMatchData TeamMatchData @relation(fields: [teamMatchKey], references: [key], onDelete: Cascade)

// year specific fields
reefscape ReefscapeSRFields?
rebuilt RebuiltSRFields?
biocore BiocoreSRFields?

}
model ReefscapeSRFields {
reportUuid String @id
report ScoutReport @relation(fields: [reportUuid], references: [uuid], onDelete: Cascade)
algaePickup AlgaePickup
coralPickup CoralPickup
bargeResult BargeResult
knocksAlgae KnocksAlgae
underShallowCage UnderShallowCage
}
model RebuiltSRFields {
reportUuid String @id
report ScoutReport @relation(fields: [reportUuid], references: [uuid], onDelete: Cascade)
accuracy Int?
beached Beached
climbPosition ClimbPosition?
Expand All @@ -76,6 +187,11 @@ model ScoutReport {
autoClimb AutoClimb
}

model BiocoreSRFields {
reportUuid String @id
report ScoutReport @relation(fields: [reportUuid], references: [uuid], onDelete: Cascade)
// TBD
}
model ScouterScheduleShift {
uuid String @id @default(uuid())
sourceTeamNumber Int
Expand Down Expand Up @@ -197,6 +313,7 @@ model Tournament {
location String?
date String?
mutablePicklists MutablePicklist[]
matches Match[]
scouterScheduleShifts ScouterScheduleShift[]
teamMatchData TeamMatchData[]
latestFetchETag String?
Expand Down Expand Up @@ -234,7 +351,74 @@ model CachedAnalysis {
tournamentDependencies String[] @default([])
}

model DataFetch {
key String @id
etag String?
createdAt DateTime @default(now())
lastTried DateTime?
lastFetched DateTime?
data String?
}

enum WarningType {
LEAVE
BREAK
}

enum UserRole {
ANALYST
SCOUTING_LEAD
}

enum MatchType {
PRACTICE
QUALIFICATION
ELIMINATION
}

enum RobotRole {
OFFENSE
DEFENSE
FEEDER
CYCLING
SCORING
FEEDING
DEFENDING
IMMOBILE
}



enum Position {
// SHARED
NONE
// REEFSCAPE
START_ONE
START_TWO
START_THREE
START_FOUR
LEVEL_ONE
LEVEL_TWO
LEVEL_THREE
LEVEL_FOUR
LEVEL_ONE_A
LEVEL_ONE_B
LEVEL_ONE_C
LEVEL_TWO_A
LEVEL_TWO_B
LEVEL_TWO_C
LEVEL_THREE_A
LEVEL_THREE_B
LEVEL_THREE_C
LEVEL_FOUR_A
LEVEL_FOUR_B
LEVEL_FOUR_C
GROUND_PIECE_A
GROUND_PIECE_B
GROUND_PIECE_C
CORAL_STATION_ONE
CORAL_STATION_TWO
// REBUILT
LEFT_TRENCH
LEFT_BUMP
HUB
Expand All @@ -243,10 +427,23 @@ enum Position {
NEUTRAL_ZONE
DEPOT
OUTPOST
NONE
}

enum EventAction {
// REEFSCAPE
PICKUP_CORAL
PICKUP_ALGAE
FEED
AUTO_LEAVE
DEFEND
SCORE_NET
FAIL_NET
SCORE_PROCESSOR
SCORE_CORAL
DROP_ALGAE
DROP_CORAL
START_POSITION
// REBUILT
START_SCORING
STOP_SCORING
START_MATCH
Expand All @@ -261,8 +458,51 @@ enum EventAction {
CLIMB
START_FEEDING
STOP_FEEDING

}

// REEFSCAPE

enum AlgaePickup {
NONE
GROUND
REEF
BOTH
}

enum KnocksAlgae {
NO
YES
}

enum AutoLeave {
NO
YES
}

enum UnderShallowCage {
NO
YES
}

enum CoralPickup {
NONE
GROUND
STATION
BOTH
}

enum BargeResult {
NOT_ATTEMPTED
PARKED
SHALLOW
FAILED_SHALLOW
DEEP
FAILED_DEEP
}

// REBUILT

enum FieldTraversal {
TRENCH
BUMP
Expand Down Expand Up @@ -313,25 +553,3 @@ enum IntakeType {
BOTH
NEITHER
}

enum RobotRole {
CYCLING
SCORING
FEEDING
DEFENDING
IMMOBILE
}

enum WarningType {
BREAK
}

enum UserRole {
ANALYST
SCOUTING_LEAD
}

enum MatchType {
QUALIFICATION
ELIMINATION
}
2 changes: 1 addition & 1 deletion railway.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 20,
"healthcheckPath": "/status",
"healthcheckTimeout": 1000
"healthcheckTimeout": 30000
},

"environments": {
Expand Down
7 changes: 7 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import posthogReporter from "./lib/middleware/posthogMiddleware.js";

import routes from "./routes/index.js";
import path from "path";
import importAllTournaments from "./lib/importAllTournaments.js";
import { requireAuth } from "./lib/middleware/requireAuth.js";

export const app = express();

Expand Down Expand Up @@ -44,3 +46,8 @@ app.use("/v1", routes); //theo was here
app.get("/status", (req, res) => {
res.status(200).send("Server running");
});

app.get("/import", requireAuth, async (req, res) => {
await importAllTournaments();
res.status(200).send("Import complete");
});
Loading
Loading