Skip to content

Commit

Permalink
parquet
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Jul 29, 2024
1 parent 4923dff commit a29b06f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
1 change: 1 addition & 0 deletions server/main-api/src/setup/database/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub async fn download_updates() -> Result<LimitedVec<Alias>, crate::BoxedError>
let cdn_url = std::env::var("CDN_URL").unwrap_or_else(|_| "https://nav.tum.de/cdn".to_string());
let body = reqwest::get(format!("{cdn_url}/api_data.parquet"))
.await?
.error_for_status()?
.bytes()
.await?;
let mut aliase=Vec::<Alias>::new();
Expand Down
2 changes: 2 additions & 0 deletions server/main-api/src/setup/database/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ pub async fn download_updates() -> Result<LimitedVec<DelocalisedValues>, crate::
let cdn_url = std::env::var("CDN_URL").unwrap_or_else(|_| "https://nav.tum.de/cdn".to_string());
let body = reqwest::get(format!("{cdn_url}/api_data.parquet"))
.await?
.error_for_status()?
.bytes()
.await?;
let mut file = tempfile()?;
Expand Down Expand Up @@ -162,6 +163,7 @@ pub async fn download_status() -> Result<LimitedVec<(String, i64)>, crate::Boxed
let cdn_url = std::env::var("CDN_URL").unwrap_or_else(|_| "https://nav.tum.de/cdn".to_string());
let body = reqwest::get(format!("{cdn_url}/status_data.parquet"))
.await?
.error_for_status()?
.bytes()
.await?;
let mut file = tempfile()?;
Expand Down
11 changes: 0 additions & 11 deletions server/main-api/src/setup/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ pub async fn setup(pool: &sqlx::PgPool) -> Result<(), crate::BoxedError> {
}
#[tracing::instrument(skip(pool))]
pub async fn load_data(pool: &sqlx::PgPool) -> Result<(), crate::BoxedError> {
let status = data::download_status().await?.0;
let new_keys = status
.clone()
.into_iter()
.map(|(k, _)| k)
.collect::<LimitedVec<String>>();
{
let mut tx = pool.begin().await?;
cleanup_deleted(&new_keys, &mut tx).await?;
tx.commit().await?;
}
{
let data = data::download_updates().await?;
let mut tx = pool.begin().await?;
Expand Down
1 change: 1 addition & 0 deletions server/main-api/src/setup/meilisearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub async fn load_data(client: &Client) -> Result<(), crate::BoxedError> {
let cdn_url = std::env::var("CDN_URL").unwrap_or_else(|_| "https://nav.tum.de/cdn".to_string());
let documents = reqwest::get(format!("{cdn_url}/search_data.json"))
.await?
.error_for_status()?
.json::<Vec<Value>>()
.await?;
let res = entries
Expand Down
4 changes: 3 additions & 1 deletion server/main-api/src/setup/transportation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ impl DBStation {
#[tracing::instrument(skip(pool))]
pub async fn setup(pool: &sqlx::PgPool) -> Result<(), crate::BoxedError> {
let url = "https://raw.githubusercontent.com/TUM-Dev/NavigaTUM/main/data/external/results/public_transport.json";
let transportations: Vec<Station> = reqwest::get(url).await?.json().await?;
let transportations = reqwest::get(url).await?
.error_for_status()?
.json::<Vec<Station>>().await?;
let transportations = transportations.into_iter().flat_map(|s| {
let id = s.station.station_id.clone();
let mut stations = vec![DBStation::from_station(s.station, None)];
Expand Down

0 comments on commit a29b06f

Please sign in to comment.