Skip to content

Commit

Permalink
fixted compilation mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed May 6, 2024
1 parent ac089e3 commit 09ab40c
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 88 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ alter table de drop column type_common_name;
alter table de add column type_common_name TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type_common_name' AS TEXT)) STORED;
alter table de drop column type;
alter table de add column type TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type' AS TEXT)) STORED;
alter table de drop column calendar_url;
alter table de add column calendar_url TEXT GENERATED ALWAYS AS (CAST (data->'props'->>'calendar_url' AS TEXT)) STORED;

alter table en alter column data type json using data::json;
Expand All @@ -28,5 +27,4 @@ alter table en drop column type_common_name;
alter table en add column type_common_name TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type_common_name' AS TEXT)) STORED;
alter table en drop column type;
alter table en add column type TEXT NOT NULL GENERATED ALWAYS AS (CAST (data->>'type' AS TEXT)) STORED;
alter table en drop column calendar_url;
alter table en add column calendar_url TEXT GENERATED ALWAYS AS (CAST (data->'props'->>'calendar_url' AS TEXT)) STORED;
4 changes: 2 additions & 2 deletions server/main-api/src/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub async fn get_handler(
Ok(d) => match d {
None => HttpResponse::NotFound().body("Not found"),
Some(d) => {
let mut response_json = d.clone();
// We don not want to serialise this data at any point in the server.
let mut response_json = serde_json::to_string(&d).unwrap();
// We don't want to serialise this data at any point in the server.
// This just flows through the server, but adding redirect_url to the response is necessary
response_json.pop(); // remove last }
response_json.push_str(&format!(",\"redirect_url\":\"{redirect_url}\"}}",));
Expand Down
3 changes: 2 additions & 1 deletion server/main-api/src/models.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use chrono::{DateTime, Utc};
use serde_json::Value;

#[derive(Debug, Clone)]
pub struct Location {
Expand All @@ -11,7 +12,7 @@ pub struct Location {
pub type_common_name: String,
pub lat: f64,
pub lon: f64,
pub data: String,
pub data: Value,
}

#[derive(Debug, Clone)]
Expand Down
27 changes: 16 additions & 11 deletions server/main-api/src/setup/database/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ use std::time::Instant;
use log::info;
use serde_json::Value;


struct DelocalisedValues {
key: String,
de: HashMap<String, Value>,
en: HashMap<String, Value>,
de: Value,
en: Value,
}

impl From<HashMap<String, Value>> for DelocalisedValues {
Expand Down Expand Up @@ -63,15 +62,21 @@ impl DelocalisedValues {
self,
tx: &mut sqlx::Transaction<'_, sqlx::Postgres>,
) -> Result<(), sqlx::Error> {
let data = serde_json::to_string(&self.de).unwrap();
sqlx::query!(r#"INSERT INTO de(key,data)VALUES ($1,$2)"#, self.key, data)
.execute(&mut **tx)
.await?;
sqlx::query!(
r#"INSERT INTO de(key,data)VALUES ($1,$2)"#,
self.key,
self.de
)
.execute(&mut **tx)
.await?;

let data = serde_json::to_string(&self.en).unwrap();
sqlx::query!(r#"INSERT INTO en(key,data)VALUES ($1,$2)"#, self.key, data)
.execute(&mut **tx)
.await?;
sqlx::query!(
r#"INSERT INTO en(key,data)VALUES ($1,$2)"#,
self.key,
self.en
)
.execute(&mut **tx)
.await?;

Ok(())
}
Expand Down

0 comments on commit 09ab40c

Please sign in to comment.