Show that DeadAir is still working on an episode (#176)
A new download in a show with DeadAir on plays at full length until its copy is made, and nothing said so. Each file now carries deadair_pending while DeadAir is on for its show and the copy is still to come (not for one heard through, which it passes over), and the episode's line and details say "Cutting dead air…". The maker sends a deadair_done event when it finishes a file, and the page takes the list again, so the line becomes how much shorter the episode is without a reload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
21
src/db.rs
21
src/db.rs
@@ -202,6 +202,7 @@ impl From<enclosures::Model> for EncRow {
|
||||
EncRow {
|
||||
id: e.id,
|
||||
deadair: None,
|
||||
deadair_pending: false,
|
||||
feed_id: e.feed_id,
|
||||
guid: e.guid,
|
||||
url: e.url,
|
||||
@@ -1184,6 +1185,10 @@ pub struct EncRow {
|
||||
/// (`deadair::for_reader`). None from the database.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub deadair: Option<i64>,
|
||||
/// DeadAir is on for this person's show and the copy is still being made: the page says to
|
||||
/// wait rather than leave them guessing (`deadair::for_reader`).
|
||||
#[serde(skip_serializing_if = "std::ops::Not::not")]
|
||||
pub deadair_pending: bool,
|
||||
pub feed_id: String,
|
||||
pub guid: String,
|
||||
pub url: String,
|
||||
@@ -2388,6 +2393,22 @@ impl Db {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Which of these enclosures DeadAir has dealt with since each was last downloaded, copy or
|
||||
/// none: the rest on disk are still waiting for it.
|
||||
pub async fn deadair_done(&self, enclosure_ids: &[i64]) -> Result<std::collections::HashSet<i64>> {
|
||||
if enclosure_ids.is_empty() {
|
||||
return Ok(Default::default());
|
||||
}
|
||||
let mut a = Args::default();
|
||||
let ids: Vec<String> = enclosure_ids.iter().map(|&i| a.p(i)).collect();
|
||||
let sql = format!(
|
||||
"SELECT d.enclosure_id FROM deadair d JOIN enclosures e ON e.id = d.enclosure_id
|
||||
WHERE d.enclosure_id IN ({}) AND d.made_at >= coalesce(e.downloaded_at, 0)",
|
||||
ids.join(", ")
|
||||
);
|
||||
self.rows(&sql, a.0).await?.iter().map(|r| Ok(r.try_get("", "enclosure_id")?)).collect()
|
||||
}
|
||||
|
||||
/// Counts an episode towards the time DeadAir has saved someone, once however often it is
|
||||
/// played.
|
||||
pub async fn count_deadair(&self, user_id: i64, feed_id: &str, guid: &str, saved_ms: i64) -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user