Skip to content

Commit

Permalink
Add imageurl column to locations table
Browse files Browse the repository at this point in the history
  • Loading branch information
SchutteJan committed Sep 20, 2023
1 parent 63d6472 commit f025ad2
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vscode
.idea
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## TODO

- Export response schema to typescript using schemars -> jsonschema -> json-schema-to-typescript
- Implement session based login using this example: https://github.com/SergioBenitez/Rocket/tree/master/examples/cookies

## System requirements
Expand Down
1 change: 0 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
target
.idea
1 change: 1 addition & 0 deletions backend/migrations/2023-09-20-194906_image_url/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE locations DROP COLUMN ImageURL;
1 change: 1 addition & 0 deletions backend/migrations/2023-09-20-194906_image_url/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE locations ADD ImageURL TEXT;
1 change: 1 addition & 0 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async fn add_bar(conn: Db, bar: Json<NewLocation>) -> Json<LocationResponse> {
description: bar.description.clone(),
osm_node_id: bar.osm_node_id.clone(),
google_place_id: bar.google_place_id.clone(),
imageurl: bar.imageurl.clone(),
};

let in_db = conn
Expand Down
4 changes: 4 additions & 0 deletions backend/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Location {
pub description: Option<String>,
pub osm_node_id: Option<String>,
pub google_place_id: Option<String>,
pub imageurl: Option<String>,
}

#[derive(Deserialize, Serialize, JsonSchema)]
Expand All @@ -29,6 +30,7 @@ pub struct LocationResponse {
pub name: String,
pub description: Option<String>,
pub coordinates: Coordinate,
pub imageurl: Option<String>,
}

#[derive(Deserialize, Insertable)]
Expand All @@ -40,6 +42,7 @@ pub struct NewLocation {
pub description: Option<String>,
pub osm_node_id: Option<String>,
pub google_place_id: Option<String>,
pub imageurl: Option<String>,
}

// TODO: Implement traits for Serde and JsonSchema for Point type
Expand All @@ -59,6 +62,7 @@ impl From<&Location> for LocationResponse {
name: l.name.clone(),
description: l.description.clone(),
coordinates: Coordinate::from(l.coordinates),
imageurl: l.imageurl.clone(),
}
}
}
1 change: 1 addition & 0 deletions backend/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ diesel::table! {
description -> Nullable<Text>,
osm_node_id -> Nullable<Varchar>,
google_place_id -> Nullable<Varchar>,
imageurl -> Nullable<Text>,
}
}

Expand Down
1 change: 1 addition & 0 deletions frontend/src/models/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface LocationResponse {
coordinates: Coordinate;
description?: string | null;
id: number;
imageurl?: string | null;
name: string;
}
export interface Coordinate {
Expand Down

0 comments on commit f025ad2

Please sign in to comment.