Skip to content

Commit

Permalink
replace map_err with inspect_err
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed Sep 16, 2024
1 parent b01dbd7 commit 2e36e97
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/scheduled_tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub async fn setup(context: Data<LemmyContext>) -> LemmyResult<()> {
delete_old_denied_users(&mut context.pool()).await;
update_instance_software(&mut context.pool(), context.client())
.await
.map_err(|e| warn!("Failed to update instance software: {e}"))
.inspect_err(|e| warn!("Failed to update instance software: {e}"))
.ok();
}
});
Expand Down Expand Up @@ -289,7 +289,7 @@ async fn delete_expired_captcha_answers(pool: &mut DbPool<'_>) {
.map(|_| {
info!("Done.");
})
.map_err(|e| error!("Failed to clear old captcha answers: {e}"))
.inspect_err(|e| error!("Failed to clear old captcha answers: {e}"))
.ok();
}
Err(e) => {
Expand All @@ -310,7 +310,7 @@ async fn clear_old_activities(pool: &mut DbPool<'_>) {
)
.execute(&mut conn)
.await
.map_err(|e| error!("Failed to clear old sent activities: {e}"))
.inspect_err(|e| error!("Failed to clear old sent activities: {e}"))
.ok();

diesel::delete(
Expand All @@ -320,7 +320,7 @@ async fn clear_old_activities(pool: &mut DbPool<'_>) {
.execute(&mut conn)
.await
.map(|_| info!("Done."))
.map_err(|e| error!("Failed to clear old received activities: {e}"))
.inspect_err(|e| error!("Failed to clear old received activities: {e}"))
.ok();
}
Err(e) => {
Expand All @@ -335,7 +335,7 @@ async fn delete_old_denied_users(pool: &mut DbPool<'_>) {
.map(|_| {
info!("Done.");
})
.map_err(|e| error!("Failed to deleted old denied users: {e}"))
.inspect_err(|e| error!("Failed to deleted old denied users: {e}"))
.ok();
}

Expand All @@ -361,7 +361,7 @@ async fn overwrite_deleted_posts_and_comments(pool: &mut DbPool<'_>) {
.map(|_| {
info!("Done.");
})
.map_err(|e| error!("Failed to overwrite deleted posts: {e}"))
.inspect_err(|e| error!("Failed to overwrite deleted posts: {e}"))
.ok();

info!("Overwriting deleted comments...");
Expand All @@ -377,7 +377,7 @@ async fn overwrite_deleted_posts_and_comments(pool: &mut DbPool<'_>) {
.map(|_| {
info!("Done.");
})
.map_err(|e| error!("Failed to overwrite deleted comments: {e}"))
.inspect_err(|e| error!("Failed to overwrite deleted comments: {e}"))
.ok();
}
Err(e) => {
Expand Down Expand Up @@ -409,14 +409,14 @@ async fn active_counts(pool: &mut DbPool<'_>) {
sql_query(update_site_stmt)
.execute(&mut conn)
.await
.map_err(|e| error!("Failed to update site stats: {e}"))
.inspect_err(|e| error!("Failed to update site stats: {e}"))
.ok();

let update_community_stmt = format!("update community_aggregates ca set users_active_{} = mv.count_ from community_aggregates_activity('{}') mv where ca.community_id = mv.community_id_", i.1, i.0);
sql_query(update_community_stmt)
.execute(&mut conn)
.await
.map_err(|e| error!("Failed to update community stats: {e}"))
.inspect_err(|e| error!("Failed to update community stats: {e}"))
.ok();
}

Expand All @@ -443,15 +443,15 @@ async fn update_banned_when_expired(pool: &mut DbPool<'_>) {
.set(person::banned.eq(false))
.execute(&mut conn)
.await
.map_err(|e| error!("Failed to update person.banned when expires: {e}"))
.inspect_err(|e| error!("Failed to update person.banned when expires: {e}"))
.ok();

diesel::delete(
community_person_ban::table.filter(community_person_ban::expires.lt(now().nullable())),
)
.execute(&mut conn)
.await
.map_err(|e| error!("Failed to remove community_ban expired rows: {e}"))
.inspect_err(|e| error!("Failed to remove community_ban expired rows: {e}"))
.ok();
}
Err(e) => {
Expand All @@ -474,7 +474,7 @@ async fn publish_scheduled_posts(context: &Data<LemmyContext>) {
//.filter(post::scheduled_time.ge(Some(now())))
.get_results::<(Post, Community)>(&mut conn)
.await
.map_err(|e| error!("Failed to read unpublished posts: {e}"))
.inspect_err(|e| error!("Failed to read unpublished posts: {e}"))
.ok();
let posts: Vec<(Post, Community)> = x
.into_iter()
Expand All @@ -488,14 +488,14 @@ async fn publish_scheduled_posts(context: &Data<LemmyContext>) {
.set(post::scheduled_time.eq(None::<DateTime<Utc>>))
.execute(&mut conn)
.await
.map_err(|e| error!("Failed update scheduled post: {e}"))
.inspect_err(|e| error!("Failed update scheduled post: {e}"))
.ok();

for p in posts {
let send_activity = SendActivityData::CreatePost(p.0.clone());
ActivityChannel::submit_activity(send_activity, context)
.await
.map_err(|e| error!("Failed federate scheduled post: {e}"))
.inspect_err(|e| error!("Failed federate scheduled post: {e}"))
.ok();
send_webmention(p.0, p.1);
}
Expand Down

0 comments on commit 2e36e97

Please sign in to comment.