From 5bac985dca3f3930d8d30b55e7924b73d723d4dc Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 26 Dec 2024 22:53:30 +0100 Subject: [PATCH] fix(cli): fix is now count --- upub/cli/src/{fix.rs => count.rs} | 8 ++++---- upub/cli/src/lib.rs | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) rename upub/cli/src/{fix.rs => count.rs} (89%) diff --git a/upub/cli/src/fix.rs b/upub/cli/src/count.rs similarity index 89% rename from upub/cli/src/fix.rs rename to upub/cli/src/count.rs index 5a1b5c8..f91d9d9 100644 --- a/upub/cli/src/fix.rs +++ b/upub/cli/src/count.rs @@ -1,11 +1,11 @@ use sea_orm::{ActiveModelTrait, EntityTrait}; -pub async fn fix(ctx: upub::Context, likes: bool, shares: bool, replies: bool) -> Result<(), sea_orm::DbErr> { +pub async fn count(ctx: upub::Context, likes: bool, shares: bool, replies: bool) -> Result<(), sea_orm::DbErr> { use futures::TryStreamExt; let db = ctx.db(); if likes { - tracing::info!("fixing likes..."); + tracing::info!("counting likes..."); let mut store = std::collections::HashMap::new(); { let mut stream = upub::model::like::Entity::find().stream(db).await?; @@ -27,7 +27,7 @@ pub async fn fix(ctx: upub::Context, likes: bool, shares: bool, replies: bool) - } if shares { - tracing::info!("fixing shares..."); + tracing::info!("counting shares..."); let mut store = std::collections::HashMap::new(); { let mut stream = upub::model::announce::Entity::find().stream(db).await?; @@ -49,7 +49,7 @@ pub async fn fix(ctx: upub::Context, likes: bool, shares: bool, replies: bool) - } if replies { - tracing::info!("fixing replies..."); + tracing::info!("counting replies..."); let mut store = std::collections::HashMap::new(); { let mut stream = upub::model::object::Entity::find().stream(db).await?; diff --git a/upub/cli/src/lib.rs b/upub/cli/src/lib.rs index 45dfbdd..c71dcb4 100644 --- a/upub/cli/src/lib.rs +++ b/upub/cli/src/lib.rs @@ -1,5 +1,5 @@ -mod fix; -pub use fix::*; +mod count; +pub use count::*; mod fetch; pub use fetch::*; @@ -54,8 +54,8 @@ pub enum CliCommand { action: RelayCommand, }, - /// run db maintenance tasks - Fix { + /// recount object statistics + Count { #[arg(long, default_value_t = false)] /// fix likes counts for posts likes: bool, @@ -147,8 +147,8 @@ pub async fn run(ctx: upub::Context, command: CliCommand) -> Result<(), Box Ok(relay(ctx, action).await?), - CliCommand::Fix { likes, shares, replies } => - Ok(fix(ctx, likes, shares, replies).await?), + CliCommand::Count { likes, shares, replies } => + Ok(count(ctx, likes, shares, replies).await?), CliCommand::Update { days, limit } => Ok(update_users(ctx, days, limit).await?), CliCommand::Register { username, password, display_name, summary, avatar_url, banner_url } =>