feat: control how many statuses to insert

This commit is contained in:
əlemi 2024-03-26 00:53:07 +01:00
parent b84a682ed4
commit 3a0ca6af86
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 6 additions and 3 deletions

View file

@ -47,7 +47,10 @@ enum CliCommand {
Migrate, Migrate,
/// generate fake user, note and activity /// 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 a single AP object
Fetch { Fetch {

View file

@ -2,7 +2,7 @@ use crate::{activitypub::PUBLIC_TARGET, model::{config, credential}};
use super::{activity, object, user, Audience}; use super::{activity, object, user, Audience};
use sea_orm::IntoActiveModel; 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}; use sea_orm::{EntityTrait, Set};
let root = super::user::Model { let root = super::user::Model {
@ -55,7 +55,7 @@ UQIDAQAB
let context = uuid::Uuid::new_v4().to_string(); 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 oid = uuid::Uuid::new_v4();
let aid = uuid::Uuid::new_v4(); let aid = uuid::Uuid::new_v4();
object::Entity::insert(object::ActiveModel { object::Entity::insert(object::ActiveModel {