Skip to content

Commit

Permalink
Merge pull request #251 from Northeastern-Electric-Racing/250-public-…
Browse files Browse the repository at this point in the history
…run-remake

Notes field of Run cleanup
  • Loading branch information
RChandler234 authored Dec 8, 2024
2 parents 0532c39 + dac4233 commit c944d04
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions angular-client/src/utils/types.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type Run = {
locationName: string;
driverName: string;
time: Date;
notes: string;
};

export type Coordinate = {
Expand Down
10 changes: 7 additions & 3 deletions scylla-server/migrations/2024-11-10-031516_create_all/down.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
-- This file should undo anything in `up.sql`
DROP TABLE "run";
-- Drop Foreign Keys
ALTER TABLE "data" DROP CONSTRAINT "data_runId_fkey";
ALTER TABLE "data" DROP CONSTRAINT "data_dataTypeName_fkey";

-- Drop Tables
DROP TABLE "data";
DROP TABLE "dataType";
DROP TABLE "dataType";
DROP TABLE "run";
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CREATE TABLE "run" (
"latitude" DOUBLE PRECISION,
"longitude" DOUBLE PRECISION,
"driverName" TEXT,
"notes" TEXT NOT NULL,
"notes" TEXT DEFAULT '',
"time" TIMESTAMPTZ NOT NULL,

CONSTRAINT "run_pkey" PRIMARY KEY ("id")
Expand Down
4 changes: 2 additions & 2 deletions scylla-server/src/services/run_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub async fn create_run(
timestamp: DateTime<Utc>,
) -> Result<Run, diesel::result::Error> {
diesel::insert_into(run)
.values((time.eq(timestamp), notes.eq("A")))
.values(time.eq(timestamp))
.get_result(db)
}

Expand All @@ -44,7 +44,7 @@ pub async fn create_run_with_id(
run_id: i32,
) -> Result<Run, diesel::result::Error> {
diesel::insert_into(run)
.values((time.eq(timestamp), id.eq(run_id), notes.eq("A")))
.values((time.eq(timestamp), id.eq(run_id)))
.get_result(db)
}

Expand Down
2 changes: 2 additions & 0 deletions scylla-server/src/transformers/run_transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct PublicRun {
pub driver_name: String,
#[serde(rename = "time")]
pub time_ms: i64,
pub notes: String,
}

impl From<crate::models::Run> for PublicRun {
Expand All @@ -19,6 +20,7 @@ impl From<crate::models::Run> for PublicRun {
location_name: value.locationName.unwrap_or_default(),
driver_name: value.driverName.clone().unwrap_or_default(),
time_ms: value.time.timestamp_millis(),
notes: value.notes,
}
}
}

0 comments on commit c944d04

Please sign in to comment.