fix(cli): fix is now count
This commit is contained in:
parent
22149f7bc7
commit
5bac985dca
2 changed files with 10 additions and 10 deletions
|
@ -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?;
|
|
@ -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<dyn
|
|||
Ok(fetch(ctx, uri, save, fetch_as).await?),
|
||||
CliCommand::Relay { action } =>
|
||||
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 } =>
|
||||
|
|
Loading…
Reference in a new issue