chore: listen to clippy

main
Jef Roosens 2025-03-31 20:13:18 +02:00
parent 823133c034
commit 974ca80298
No known key found for this signature in database
GPG Key ID: 21FD3D77D56BAF49
7 changed files with 13 additions and 29 deletions

View File

@ -71,11 +71,10 @@ pub struct AddQueryDebugLogs;
impl CustomizeConnection<SqliteConnection, diesel::r2d2::Error> for AddQueryDebugLogs { impl CustomizeConnection<SqliteConnection, diesel::r2d2::Error> for AddQueryDebugLogs {
fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<(), diesel::r2d2::Error> { fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<(), diesel::r2d2::Error> {
conn.set_instrumentation(|event: InstrumentationEvent<'_>| match event { conn.set_instrumentation(|event: InstrumentationEvent<'_>| {
InstrumentationEvent::StartQuery { query, .. } => { if let InstrumentationEvent::StartQuery { query, .. } = event {
tracing::debug!("{}", query); tracing::debug!("{}", query);
} }
_ => {}
}); });
Ok(()) Ok(())

View File

@ -58,21 +58,6 @@ impl Device {
) )
.get_result(conn) .get_result(conn)
} }
pub fn by_device_id(
conn: &mut SqliteConnection,
user_id: i64,
device_id: &str,
) -> diesel::QueryResult<Self> {
devices::dsl::devices
.select(Self::as_select())
.filter(
devices::user_id
.eq(user_id)
.and(devices::device_id.eq(device_id)),
)
.get_result(conn)
}
} }
impl NewDevice { impl NewDevice {

View File

@ -1,7 +1,7 @@
use std::collections::HashSet; use std::collections::HashSet;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use diesel::{alias, dsl::not, prelude::*, sqlite::Sqlite}; use diesel::{alias, dsl::not, prelude::*};
use gpodder::AuthErr; use gpodder::AuthErr;
use super::SqliteRepository; use super::SqliteRepository;
@ -100,7 +100,7 @@ impl gpodder::DeviceRepository for SqliteRepository {
let device = NewDevice { let device = NewDevice {
device_id: device_id.to_string(), device_id: device_id.to_string(),
user_id: user.id, user_id: user.id,
caption: patch.caption.unwrap_or(String::new()), caption: patch.caption.unwrap_or_default(),
type_: patch.r#type.unwrap_or(gpodder::DeviceType::Other).into(), type_: patch.r#type.unwrap_or(gpodder::DeviceType::Other).into(),
}; };

View File

@ -29,7 +29,7 @@ fn set_subscriptions_for_single_device(
.collect(); .collect();
// URLs originally in the database that are no longer in the list // URLs originally in the database that are no longer in the list
let urls_to_delete = urls_in_db.difference(&urls); let urls_to_delete = urls_in_db.difference(urls);
// URLs not in the database that are in the new list // URLs not in the database that are in the new list
let urls_to_insert = urls.difference(&urls_in_db); let urls_to_insert = urls.difference(&urls_in_db);

View File

@ -20,7 +20,7 @@ impl Command {
match self { match self {
Self::Sync { username, devices } => { Self::Sync { username, devices } => {
let user = store.get_user(&username).unwrap(); let user = store.get_user(username).unwrap();
store store
.update_device_sync_status( .update_device_sync_status(
&user, &user,
@ -30,7 +30,7 @@ impl Command {
.unwrap(); .unwrap();
} }
Self::Devices { username } => { Self::Devices { username } => {
let user = store.get_user(&username).unwrap(); let user = store.get_user(username).unwrap();
let devices = store.devices_for_user(&user).unwrap(); let devices = store.devices_for_user(&user).unwrap();
for device in devices { for device in devices {

View File

@ -24,7 +24,10 @@ pub fn router(ctx: Context) -> Router<Context> {
"/{username}", "/{username}",
post(post_episode_actions).get(get_episode_actions), post(post_episode_actions).get(get_episode_actions),
) )
.layer(middleware::from_fn_with_state(ctx.clone(), auth_api_middleware)) .layer(middleware::from_fn_with_state(
ctx.clone(),
auth_api_middleware,
))
} }
async fn post_episode_actions( async fn post_episode_actions(
@ -84,10 +87,7 @@ async fn get_episode_actions(
return Err(AppError::BadRequest); return Err(AppError::BadRequest);
} }
let since = filter let since = filter.since.and_then(|ts| DateTime::from_timestamp(ts, 0));
.since
.map(|ts| DateTime::from_timestamp(ts, 0))
.flatten();
Ok(tokio::task::spawn_blocking(move || { Ok(tokio::task::spawn_blocking(move || {
ctx.store.episode_actions_for_user( ctx.store.episode_actions_for_user(

View File

@ -47,7 +47,7 @@ pub struct TemplateResponse<T> {
impl<T> TemplateResponse<T> { impl<T> TemplateResponse<T> {
pub fn new(tera: &Arc<tera::Tera>, template: T) -> Self { pub fn new(tera: &Arc<tera::Tera>, template: T) -> Self {
Self { Self {
tera: Arc::clone(&tera), tera: Arc::clone(tera),
template, template,
} }
} }