From 3a0ca6af86dd1e9ed6af7bdd6f20814c6043be38 Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 26 Mar 2024 00:53:07 +0100 Subject: [PATCH] feat: control how many statuses to insert --- src/main.rs | 5 ++++- src/model/faker.rs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1f03e1c0..43bd4553 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,7 +47,10 @@ enum CliCommand { Migrate, /// generate fake user, note and activity - Faker, + Faker{ + /// how many fake statuses to insert for root user + count: usize, + }, /// fetch a single AP object Fetch { diff --git a/src/model/faker.rs b/src/model/faker.rs index a80f7957..65ed55a9 100644 --- a/src/model/faker.rs +++ b/src/model/faker.rs @@ -2,7 +2,7 @@ use crate::{activitypub::PUBLIC_TARGET, model::{config, credential}}; use super::{activity, object, user, Audience}; use sea_orm::IntoActiveModel; -pub async fn faker(db: &sea_orm::DatabaseConnection, domain: String) -> Result<(), sea_orm::DbErr> { +pub async fn faker(db: &sea_orm::DatabaseConnection, domain: String, count: usize) -> Result<(), sea_orm::DbErr> { use sea_orm::{EntityTrait, Set}; let root = super::user::Model { @@ -55,7 +55,7 @@ UQIDAQAB let context = uuid::Uuid::new_v4().to_string(); - for i in (0..100).rev() { + for i in (0..count).rev() { let oid = uuid::Uuid::new_v4(); let aid = uuid::Uuid::new_v4(); object::Entity::insert(object::ActiveModel {