fix: track last_event per relay on the dashboard
relay_url was being destructured as .. and thrown away, so update_relay_last_event was called with an empty string and matched no rows. Capture relay_url from the notification and pass it through so each relay row gets its last_event updated.
This commit is contained in:
+4
-4
@@ -101,9 +101,9 @@ async fn run_reader(cfg: Arc<Config>, pool: SqlitePool, connected: Arc<AtomicI32
|
||||
let blossom = blossom.clone();
|
||||
async move {
|
||||
match notification {
|
||||
RelayPoolNotification::Event { event, .. } => {
|
||||
RelayPoolNotification::Event { relay_url, event, .. } => {
|
||||
match event.kind.as_u16() {
|
||||
2003 => handle_torrent(&pool, &cfg, &enricher, blossom.as_deref(), &event).await,
|
||||
2003 => handle_torrent(&pool, &cfg, &enricher, blossom.as_deref(), relay_url.as_str(), &event).await,
|
||||
30004 => handle_curation_set(&pool, &event).await,
|
||||
1984 => handle_report(&pool, &cfg, &event).await,
|
||||
_ => {}
|
||||
@@ -128,7 +128,7 @@ async fn run_reader(cfg: Arc<Config>, pool: SqlitePool, connected: Arc<AtomicI32
|
||||
connected.store(0, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
async fn handle_torrent(pool: &SqlitePool, cfg: &Config, enricher: &Enricher, blossom: Option<&BlossomClient>, event: &nostr_sdk::Event) {
|
||||
async fn handle_torrent(pool: &SqlitePool, cfg: &Config, enricher: &Enricher, blossom: Option<&BlossomClient>, relay_url: &str, event: &nostr_sdk::Event) {
|
||||
match super::parser::parse(event) {
|
||||
Ok(rec) => {
|
||||
// WoT / block / mute check
|
||||
@@ -166,7 +166,7 @@ async fn handle_torrent(pool: &SqlitePool, cfg: &Config, enricher: &Enricher, bl
|
||||
Err(e) => error!(event_id = %event.id, "db insert failed: {e}"),
|
||||
Ok(()) => {
|
||||
debug!(event_id = %event.id, title = %rec.title, "indexed torrent");
|
||||
let _ = db::update_relay_last_event(pool, "", event.created_at.as_secs() as i64).await;
|
||||
let _ = db::update_relay_last_event(pool, relay_url, event.created_at.as_secs() as i64).await;
|
||||
|
||||
if enricher.enabled() && rec.tmdb_id.is_empty() {
|
||||
let enricher = enricher.clone();
|
||||
|
||||
Reference in New Issue
Block a user