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 {
fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<(), diesel::r2d2::Error> {
conn.set_instrumentation(|event: InstrumentationEvent<'_>| match event {
InstrumentationEvent::StartQuery { query, .. } => {
conn.set_instrumentation(|event: InstrumentationEvent<'_>| {
if let InstrumentationEvent::StartQuery { query, .. } = event {
tracing::debug!("{}", query);
}
_ => {}
});
Ok(())

View File

@ -58,21 +58,6 @@ impl Device {
)
.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 {

View File

@ -1,7 +1,7 @@
use std::collections::HashSet;
use chrono::{DateTime, Utc};
use diesel::{alias, dsl::not, prelude::*, sqlite::Sqlite};
use diesel::{alias, dsl::not, prelude::*};
use gpodder::AuthErr;
use super::SqliteRepository;
@ -100,7 +100,7 @@ impl gpodder::DeviceRepository for SqliteRepository {
let device = NewDevice {
device_id: device_id.to_string(),
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(),
};

View File

@ -29,7 +29,7 @@ fn set_subscriptions_for_single_device(
.collect();
// 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
let urls_to_insert = urls.difference(&urls_in_db);

View File

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

View File

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

View File

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