fix: clippy warnings in wrapup compute + renderer
Some checks failed
CI / Check / Test (push) Has been cancelled
Some checks failed
CI / Check / Test (push) Has been cancelled
This commit is contained in:
@@ -22,7 +22,11 @@ pub async fn execute(
|
||||
Ok(build_report(query.scope, query.date_range, &rows))
|
||||
}
|
||||
|
||||
fn build_report(scope: WrapUpScope, date_range: DateRange, rows: &[WrapUpMovieRow]) -> WrapUpReport {
|
||||
fn build_report(
|
||||
scope: WrapUpScope,
|
||||
date_range: DateRange,
|
||||
rows: &[WrapUpMovieRow],
|
||||
) -> WrapUpReport {
|
||||
let total_movies = rows.len() as u32;
|
||||
|
||||
let total_watch_time_minutes: u32 = rows.iter().filter_map(|r| r.runtime_minutes).sum();
|
||||
@@ -179,7 +183,10 @@ fn compute_busiest_day(rows: &[WrapUpMovieRow]) -> Option<String> {
|
||||
}
|
||||
|
||||
fn compute_runtime_extremes(rows: &[WrapUpMovieRow]) -> (Option<MovieRef>, Option<MovieRef>) {
|
||||
let with_runtime: Vec<_> = rows.iter().filter(|r| r.runtime_minutes.is_some()).collect();
|
||||
let with_runtime: Vec<_> = rows
|
||||
.iter()
|
||||
.filter(|r| r.runtime_minutes.is_some())
|
||||
.collect();
|
||||
let longest = with_runtime
|
||||
.iter()
|
||||
.max_by_key(|r| r.runtime_minutes.unwrap_or(0))
|
||||
@@ -192,22 +199,20 @@ fn compute_runtime_extremes(rows: &[WrapUpMovieRow]) -> (Option<MovieRef>, Optio
|
||||
}
|
||||
|
||||
fn compute_rating_extremes(rows: &[WrapUpMovieRow]) -> (Option<MovieRef>, Option<MovieRef>) {
|
||||
let highest = rows.iter().max_by_key(|r| r.rating).map(|r| movie_ref(r));
|
||||
let lowest = rows.iter().min_by_key(|r| r.rating).map(|r| movie_ref(r));
|
||||
let highest = rows.iter().max_by_key(|r| r.rating).map(movie_ref);
|
||||
let lowest = rows.iter().min_by_key(|r| r.rating).map(movie_ref);
|
||||
(highest, lowest)
|
||||
}
|
||||
|
||||
fn compute_chronological_extremes(
|
||||
rows: &[WrapUpMovieRow],
|
||||
) -> (Option<MovieRef>, Option<MovieRef>) {
|
||||
fn compute_chronological_extremes(rows: &[WrapUpMovieRow]) -> (Option<MovieRef>, Option<MovieRef>) {
|
||||
let first = rows
|
||||
.iter()
|
||||
.min_by_key(|r| r.watched_at)
|
||||
.map(|r| movie_ref(r));
|
||||
.map(movie_ref);
|
||||
let last = rows
|
||||
.iter()
|
||||
.max_by_key(|r| r.watched_at)
|
||||
.map(|r| movie_ref(r));
|
||||
.map(movie_ref);
|
||||
(first, last)
|
||||
}
|
||||
|
||||
@@ -215,11 +220,11 @@ fn compute_year_extremes(rows: &[WrapUpMovieRow]) -> (Option<MovieRef>, Option<M
|
||||
let oldest = rows
|
||||
.iter()
|
||||
.min_by_key(|r| r.release_year)
|
||||
.map(|r| movie_ref(r));
|
||||
.map(movie_ref);
|
||||
let newest = rows
|
||||
.iter()
|
||||
.max_by_key(|r| r.release_year)
|
||||
.map(|r| movie_ref(r));
|
||||
.map(movie_ref);
|
||||
(oldest, newest)
|
||||
}
|
||||
|
||||
@@ -246,7 +251,11 @@ fn compute_director_stats(rows: &[WrapUpMovieRow]) -> (Vec<PersonStat>, u32) {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
stats.sort_by(|a, b| b.count.cmp(&a.count).then(b.avg_rating.total_cmp(&a.avg_rating)));
|
||||
stats.sort_by(|a, b| {
|
||||
b.count
|
||||
.cmp(&a.count)
|
||||
.then(b.avg_rating.total_cmp(&a.avg_rating))
|
||||
});
|
||||
stats.truncate(5);
|
||||
(stats, diversity)
|
||||
}
|
||||
@@ -257,10 +266,7 @@ fn compute_actor_stats(rows: &[WrapUpMovieRow]) -> (Vec<PersonStat>, u32, Vec<St
|
||||
for r in rows {
|
||||
for (i, (name, billing)) in r.cast_names.iter().enumerate() {
|
||||
if *billing <= 3 {
|
||||
actor_movies
|
||||
.entry(name.clone())
|
||||
.or_default()
|
||||
.push(r.rating);
|
||||
actor_movies.entry(name.clone()).or_default().push(r.rating);
|
||||
if let Some(path) = r.cast_profile_paths.get(i) {
|
||||
actor_profiles
|
||||
.entry(name.clone())
|
||||
@@ -282,7 +288,11 @@ fn compute_actor_stats(rows: &[WrapUpMovieRow]) -> (Vec<PersonStat>, u32, Vec<St
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
stats.sort_by(|a, b| b.count.cmp(&a.count).then(b.avg_rating.total_cmp(&a.avg_rating)));
|
||||
stats.sort_by(|a, b| {
|
||||
b.count
|
||||
.cmp(&a.count)
|
||||
.then(b.avg_rating.total_cmp(&a.avg_rating))
|
||||
});
|
||||
stats.truncate(5);
|
||||
let profile_paths: Vec<String> = stats
|
||||
.iter()
|
||||
@@ -316,7 +326,7 @@ fn compute_genre_stats(
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
stats.sort_by(|a, b| b.count.cmp(&a.count));
|
||||
stats.sort_by_key(|s| std::cmp::Reverse(s.count));
|
||||
let highest = stats
|
||||
.iter()
|
||||
.max_by(|a, b| a.avg_rating.total_cmp(&b.avg_rating))
|
||||
@@ -341,7 +351,7 @@ fn compute_keyword_stats(rows: &[WrapUpMovieRow]) -> Vec<KeywordStat> {
|
||||
.into_iter()
|
||||
.map(|(keyword, count)| KeywordStat { keyword, count })
|
||||
.collect();
|
||||
stats.sort_by(|a, b| b.count.cmp(&a.count));
|
||||
stats.sort_by_key(|s| std::cmp::Reverse(s.count));
|
||||
stats.truncate(20);
|
||||
stats
|
||||
}
|
||||
@@ -371,7 +381,7 @@ fn compute_language_stats(rows: &[WrapUpMovieRow]) -> Vec<LangStat> {
|
||||
.into_iter()
|
||||
.map(|(language, count)| LangStat { language, count })
|
||||
.collect();
|
||||
stats.sort_by(|a, b| b.count.cmp(&a.count));
|
||||
stats.sort_by_key(|s| std::cmp::Reverse(s.count));
|
||||
stats
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,10 @@ pub async fn execute(
|
||||
Ok(report) => {
|
||||
let json = serde_json::to_string(&report)
|
||||
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
|
||||
ctx.repos.wrapup_repo.set_complete(&wrapup_id, &json).await?;
|
||||
ctx.repos
|
||||
.wrapup_repo
|
||||
.set_complete(&wrapup_id, &json)
|
||||
.await?;
|
||||
|
||||
// Optionally render video (non-fatal)
|
||||
if let Some(ref renderer) = ctx.services.video_renderer {
|
||||
@@ -51,7 +54,12 @@ pub async fn execute(
|
||||
match renderer.render(&report, poster_images, &config).await {
|
||||
Ok(video_bytes) => {
|
||||
let video_key = format!("wrapups/{}/video.mp4", wrapup_id.value());
|
||||
if let Err(e) = ctx.services.image_storage.store(&video_key, &video_bytes).await {
|
||||
if let Err(e) = ctx
|
||||
.services
|
||||
.image_storage
|
||||
.store(&video_key, &video_bytes)
|
||||
.await
|
||||
{
|
||||
tracing::warn!("failed to store wrapup video: {e}");
|
||||
}
|
||||
}
|
||||
@@ -80,9 +88,8 @@ pub async fn execute(
|
||||
async fn resolve_poster_images(ctx: &AppContext, report: &WrapUpReport) -> Vec<(String, Vec<u8>)> {
|
||||
let mut images = Vec::new();
|
||||
for path in report.poster_paths.iter().take(20) {
|
||||
match ctx.services.image_storage.get(path).await {
|
||||
Ok(bytes) => images.push((path.clone(), bytes)),
|
||||
Err(_) => {}
|
||||
if let Ok(bytes) = ctx.services.image_storage.get(path).await {
|
||||
images.push((path.clone(), bytes));
|
||||
}
|
||||
}
|
||||
images
|
||||
|
||||
Reference in New Issue
Block a user