Skip to content

Commit

Permalink
Simplify sync
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Oct 18, 2023
1 parent bbecabd commit d37a9de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/command/sync.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::model::element;
use crate::model::event::Event;
use crate::model::user;
use crate::model::Element;
Expand All @@ -14,6 +13,8 @@ use rusqlite::Transaction;
use serde_json::Value;
use std::collections::HashSet;
use std::time::SystemTime;
use time::format_description::well_known::Rfc3339;
use time::OffsetDateTime;
use tokio::time::sleep;
use tokio::time::Duration;
use tracing::error;
Expand Down Expand Up @@ -113,9 +114,10 @@ async fn process_elements(fresh_elements: Vec<OverpassElement>, mut db: Connecti
);

info!(element.id, "Marking element as deleted");
tx.execute(
element::MARK_AS_DELETED,
named_params! { ":id": element.id },
Element::set_deleted_at(
&element.id,
&OffsetDateTime::now_utc().format(&Rfc3339).unwrap(),
&tx,
)?;
sleep(Duration::from_millis(10)).await;
}
Expand Down
6 changes: 0 additions & 6 deletions src/model/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,6 @@ impl Element {
}
}

pub static MARK_AS_DELETED: &str = r#"
UPDATE element
SET deleted_at = strftime('%Y-%m-%dT%H:%M:%fZ')
WHERE id = :id
"#;

const fn full_mapper() -> fn(&Row) -> rusqlite::Result<Element> {
|row: &Row| -> rusqlite::Result<Element> {
let osm_json: String = row.get(1)?;
Expand Down

0 comments on commit d37a9de

Please sign in to comment.