feat: create 100 fake entities

This commit is contained in:
əlemi 2024-03-20 07:53:45 +01:00
parent b4c68c5c73
commit 8a4e40c93a
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -15,24 +15,28 @@ pub async fn faker(db: &sea_orm::DatabaseConnection) -> Result<(), sea_orm::DbEr
actor_type: sea_orm::Set(super::activitystream::object::actor::ActorType::Person), actor_type: sea_orm::Set(super::activitystream::object::actor::ActorType::Person),
}).exec(db).await?; }).exec(db).await?;
object::Entity::insert(object::ActiveModel { for i in (0..100).rev() {
id: sea_orm::Set("http://localhost:3000/objects/4e28d30b-33c1-4336-918b-6fbe592bdd44".into()), let oid = uuid::Uuid::new_v4();
name: sea_orm::Set(None), let aid = uuid::Uuid::new_v4();
object_type: sea_orm::Set(crate::activitystream::object::ObjectType::Note), object::Entity::insert(object::ActiveModel {
attributed_to: sea_orm::Set(Some("http://localhost:3000/users/root".into())), id: sea_orm::Set(format!("http://localhost:3000/objects/{oid}")),
summary: sea_orm::Set(None), name: sea_orm::Set(None),
content: sea_orm::Set(Some("Hello world!".into())), object_type: sea_orm::Set(crate::activitystream::object::ObjectType::Note),
published: sea_orm::Set(chrono::Utc::now()), attributed_to: sea_orm::Set(Some("http://localhost:3000/users/root".into())),
}).exec(db).await?; summary: sea_orm::Set(None),
content: sea_orm::Set(Some(format!("Hello world! {i}"))),
published: sea_orm::Set(chrono::Utc::now() - std::time::Duration::from_secs(60*i)),
}).exec(db).await?;
activity::Entity::insert(activity::ActiveModel { activity::Entity::insert(activity::ActiveModel {
id: sea_orm::Set("http://localhost:3000/activities/ebac57e1-9828-438c-be34-a44a52de7641".into()), id: sea_orm::Set(format!("http://localhost:3000/activities/{aid}")),
activity_type: sea_orm::Set(crate::activitystream::object::activity::ActivityType::Create), activity_type: sea_orm::Set(crate::activitystream::object::activity::ActivityType::Create),
actor: sea_orm::Set("http://localhost:3000/users/root".into()), actor: sea_orm::Set("http://localhost:3000/users/root".into()),
object: sea_orm::Set(Some("http://localhost:3000/obkects/4e28d30b-33c1-4336-918b-6fbe592bdd44".into())), object: sea_orm::Set(Some(format!("http://localhost:3000/objects/{oid}"))),
target: sea_orm::Set(None), target: sea_orm::Set(None),
published: sea_orm::Set(chrono::Utc::now()), published: sea_orm::Set(chrono::Utc::now() - std::time::Duration::from_secs(60*i)),
}).exec(db).await?; }).exec(db).await?;
}
Ok(()) Ok(())
} }