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};
|
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;
|
use futures::TryStreamExt;
|
||||||
let db = ctx.db();
|
let db = ctx.db();
|
||||||
|
|
||||||
if likes {
|
if likes {
|
||||||
tracing::info!("fixing likes...");
|
tracing::info!("counting likes...");
|
||||||
let mut store = std::collections::HashMap::new();
|
let mut store = std::collections::HashMap::new();
|
||||||
{
|
{
|
||||||
let mut stream = upub::model::like::Entity::find().stream(db).await?;
|
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 {
|
if shares {
|
||||||
tracing::info!("fixing shares...");
|
tracing::info!("counting shares...");
|
||||||
let mut store = std::collections::HashMap::new();
|
let mut store = std::collections::HashMap::new();
|
||||||
{
|
{
|
||||||
let mut stream = upub::model::announce::Entity::find().stream(db).await?;
|
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 {
|
if replies {
|
||||||
tracing::info!("fixing replies...");
|
tracing::info!("counting replies...");
|
||||||
let mut store = std::collections::HashMap::new();
|
let mut store = std::collections::HashMap::new();
|
||||||
{
|
{
|
||||||
let mut stream = upub::model::object::Entity::find().stream(db).await?;
|
let mut stream = upub::model::object::Entity::find().stream(db).await?;
|
|
@ -1,5 +1,5 @@
|
||||||
mod fix;
|
mod count;
|
||||||
pub use fix::*;
|
pub use count::*;
|
||||||
|
|
||||||
mod fetch;
|
mod fetch;
|
||||||
pub use fetch::*;
|
pub use fetch::*;
|
||||||
|
@ -54,8 +54,8 @@ pub enum CliCommand {
|
||||||
action: RelayCommand,
|
action: RelayCommand,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// run db maintenance tasks
|
/// recount object statistics
|
||||||
Fix {
|
Count {
|
||||||
#[arg(long, default_value_t = false)]
|
#[arg(long, default_value_t = false)]
|
||||||
/// fix likes counts for posts
|
/// fix likes counts for posts
|
||||||
likes: bool,
|
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?),
|
Ok(fetch(ctx, uri, save, fetch_as).await?),
|
||||||
CliCommand::Relay { action } =>
|
CliCommand::Relay { action } =>
|
||||||
Ok(relay(ctx, action).await?),
|
Ok(relay(ctx, action).await?),
|
||||||
CliCommand::Fix { likes, shares, replies } =>
|
CliCommand::Count { likes, shares, replies } =>
|
||||||
Ok(fix(ctx, likes, shares, replies).await?),
|
Ok(count(ctx, likes, shares, replies).await?),
|
||||||
CliCommand::Update { days, limit } =>
|
CliCommand::Update { days, limit } =>
|
||||||
Ok(update_users(ctx, days, limit).await?),
|
Ok(update_users(ctx, days, limit).await?),
|
||||||
CliCommand::Register { username, password, display_name, summary, avatar_url, banner_url } =>
|
CliCommand::Register { username, password, display_name, summary, avatar_url, banner_url } =>
|
||||||
|
|
Loading…
Reference in a new issue