From 87954f0c98c4a0809529593f4a6d8997b7d66cd3 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 25 Jan 2024 15:09:35 +0100 Subject: [PATCH] fix --- crates/db_perf/Cargo.toml | 1 + crates/db_perf/src/main.rs | 31 ++++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/crates/db_perf/Cargo.toml b/crates/db_perf/Cargo.toml index 87d2a58ac..1e74b4966 100644 --- a/crates/db_perf/Cargo.toml +++ b/crates/db_perf/Cargo.toml @@ -21,3 +21,4 @@ lemmy_db_schema = { workspace = true } lemmy_db_views = { workspace = true, features = ["full"] } lemmy_utils = { workspace = true } tokio = { workspace = true } +url = { workspace = true } diff --git a/crates/db_perf/src/main.rs b/crates/db_perf/src/main.rs index 9d393bf0a..c7af7c23b 100644 --- a/crates/db_perf/src/main.rs +++ b/crates/db_perf/src/main.rs @@ -16,17 +16,16 @@ use lemmy_db_schema::{ community::{Community, CommunityInsertForm}, instance::Instance, person::{Person, PersonInsertForm}, + site::Site, }, traits::Crud, utils::{build_db_pool, get_conn, now}, SortType, }; -use lemmy_db_views::{ - post_view::PostQuery, - structs::{PaginationCursor, SiteView}, -}; +use lemmy_db_views::{post_view::PostQuery, structs::PaginationCursor}; use lemmy_utils::error::{LemmyErrorExt2, LemmyResult}; use std::num::NonZeroU32; +use url::Url; #[derive(Parser, Debug)] struct CmdArgs { @@ -148,8 +147,6 @@ async fn try_main() -> LemmyResult<()> { page_after.is_some() ); - let site = SiteView::read_local(&mut (&build_db_pool().await?).into()).await?; - // TODO: include local_user let post_views = PostQuery { community_id: community_ids.as_slice().first().cloned(), @@ -158,7 +155,7 @@ async fn try_main() -> LemmyResult<()> { page_after, ..Default::default() } - .list(&site.site, &mut conn.into()) + .list(&site()?, &mut conn.into()) .await?; if let Some(post_view) = post_views.into_iter().last() { @@ -182,3 +179,23 @@ async fn try_main() -> LemmyResult<()> { Ok(()) } + +fn site() -> LemmyResult { + Ok(Site { + id: Default::default(), + name: "".to_string(), + sidebar: None, + published: Default::default(), + updated: None, + icon: None, + banner: None, + description: None, + actor_id: Url::parse("http://example.com")?.into(), + last_refreshed_at: Default::default(), + inbox_url: Url::parse("http://example.com")?.into(), + private_key: None, + public_key: "".to_string(), + instance_id: Default::default(), + content_warning: None, + }) +}