rename runs to successful_runs
This commit is contained in:
parent
2de9c744d7
commit
4434a31c09
2 changed files with 9 additions and 9 deletions
|
|
@ -1,7 +1,6 @@
|
|||
CREATE TABLE IF NOT EXISTS runs (
|
||||
CREATE TABLE IF NOT EXISTS successful_runs (
|
||||
id INTEGER PRIMARY KEY,
|
||||
date_time DATETIME NOT NULL DEFAULT current_timestamp,
|
||||
succeeded BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
feed INTEGER NOT NULL,
|
||||
FOREIGN KEY (feed) REFERENCES feeds(id)
|
||||
);
|
||||
|
|
|
|||
11
src/lib.rs
11
src/lib.rs
|
|
@ -167,10 +167,8 @@ async fn check_feeds(db: &SqlitePool, client: &reqwest::Client) {
|
|||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
}
|
||||
if success
|
||||
&& let Err(e) = sqlx::query!(
|
||||
"insert into runs (feed, succeeded) values (?, true)",
|
||||
feed_id
|
||||
)
|
||||
&& let Err(e) =
|
||||
sqlx::query!("insert into successful_runs (feed) values (?)", feed_id)
|
||||
.execute(db)
|
||||
.await
|
||||
{
|
||||
|
|
@ -188,13 +186,14 @@ async fn check_feed(
|
|||
url: String,
|
||||
) -> Result<Option<Vec<FeedEntry>>, String> {
|
||||
let rec = sqlx::query!(
|
||||
"select date_time from runs where succeeded = true and feed = ? order by id desc limit 1",
|
||||
"select date_time from successful_runs where feed = ? order by id desc limit 1",
|
||||
feed_id
|
||||
)
|
||||
.fetch_optional(&db)
|
||||
.await
|
||||
.map_err(|e| format!("Could not fetch runs for {url} from DB, got {e}"))?;
|
||||
|
||||
tracing::debug!("checking {url}");
|
||||
let last_fetched = rec.map(|d| d.date_time.and_utc()).unwrap_or(LAST_FETCHED);
|
||||
let now = Utc::now();
|
||||
let mut out = Vec::new();
|
||||
|
|
@ -241,8 +240,10 @@ async fn check_feed(
|
|||
}
|
||||
|
||||
if out.is_empty() {
|
||||
tracing::debug!("no new items from {url}");
|
||||
Ok(None)
|
||||
} else {
|
||||
tracing::debug!("found {} new items from {url}", out.len());
|
||||
Ok(Some(out))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue