Separate feed entry id and entry_id
This commit is contained in:
parent
2a11ae6d99
commit
7279ff3e2a
6
justfile
6
justfile
@ -4,10 +4,14 @@ _default:
|
||||
# Don't use this secret key for your own install, it's public!
|
||||
export SECRET_KEY := "MHSePvm1msyOkYuJ7u+MtyJYCzgdHCS7QNvrk9ts+rI="
|
||||
|
||||
[doc("Run the reader locally in demo mode.")] # don't re-use this secret key
|
||||
[doc("Run the reader locally in demo mode.")]
|
||||
run-local-demo *args:
|
||||
cargo run -- --demo {{args}}
|
||||
|
||||
# Run the reader locally against a persistent sqlite database
|
||||
run-local-persistant-db *args:
|
||||
cargo run -- --database data.sqlite
|
||||
|
||||
sqlx-prepare:
|
||||
DATABASE_URL="sqlite:data.sqlite" cargo sqlx prepare
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
CREATE TABLE feed_entries (
|
||||
id TEXT PRIMARY KEY,
|
||||
feed_id TEXT NOT NULL,
|
||||
entry_id TEXT NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
published TIMESTAMP,
|
||||
updated TIMESTAMP,
|
||||
@ -10,4 +11,4 @@ CREATE TABLE feed_entries (
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
FOREIGN KEY (feed_id) REFERENCES feeds(feed_id) ON DELETE CASCADE,
|
||||
UNIQUE(feed_id, id)
|
||||
);
|
||||
);
|
||||
|
@ -21,7 +21,8 @@ pub struct FeedPollResponse {
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(crate = "rocket::serde")]
|
||||
struct Entry {
|
||||
id: String,
|
||||
id: Uuid,
|
||||
entry_id: String,
|
||||
title: String,
|
||||
published: Option<DateTime<Utc>>,
|
||||
updated: Option<DateTime<Utc>>,
|
||||
@ -52,7 +53,7 @@ async fn update_entry_db(
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
INSERT INTO feed_entries (
|
||||
id, feed_id, title, published, updated, summary, content, link, created_at
|
||||
id, feed_id, entry_id, title, published, updated, summary, content, link, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT (feed_id, id) DO UPDATE SET
|
||||
title = excluded.title,
|
||||
@ -65,6 +66,7 @@ async fn update_entry_db(
|
||||
)
|
||||
.bind(&entry.id)
|
||||
.bind(feed_id)
|
||||
.bind(&entry.entry_id)
|
||||
.bind(&entry.title)
|
||||
.bind(entry.published.map(|dt| dt.to_rfc3339()))
|
||||
.bind(entry.updated.map(|dt| dt.to_rfc3339()))
|
||||
@ -107,7 +109,8 @@ async fn fetch_new_entries(url: &Url) -> Result<Vec<Entry>, Status> {
|
||||
.entries
|
||||
.into_iter()
|
||||
.map(|feed_entry| Entry {
|
||||
id: feed_entry.id,
|
||||
id: Uuid::new_v4(),
|
||||
entry_id: feed_entry.id,
|
||||
title: get(feed_entry.title, "title"),
|
||||
published: feed_entry.published,
|
||||
updated: feed_entry.updated,
|
||||
|
Loading…
Reference in New Issue
Block a user