use diesel::{result::Error, *};
-use lemmy_db_queries::{aggregates::site_aggregates::SiteAggregates, ToSafe};
use lemmy_db_schema::{
- schema::{site, site_aggregates, person},
- source::{
- site::Site,
- person::{PersonSafe, Person},
- },
+ aggregates::site_aggregates::SiteAggregates,
+ schema::{site, site_aggregates},
+ source::site::Site,
};
-use serde::Serialize;
+use serde::{Deserialize, Serialize};
-#[derive(Debug, Serialize, Clone)]
+#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SiteView {
pub site: Site,
- pub creator: PersonSafe,
pub counts: SiteAggregates,
}
impl SiteView {
pub fn read(conn: &PgConnection) -> Result<Self, Error> {
- let (site, creator, counts) = site::table
- .inner_join(person::table)
+ let (site, counts) = site::table
.inner_join(site_aggregates::table)
- .select((
- site::all_columns,
- Person::safe_columns_tuple(),
- site_aggregates::all_columns,
- ))
- .first::<(Site, PersonSafe, SiteAggregates)>(conn)?;
+ .select((site::all_columns, site_aggregates::all_columns))
+ .first::<(Site, SiteAggregates)>(conn)?;
- Ok(SiteView {
- site,
- creator,
- counts,
- })
+ Ok(SiteView { site, counts })
}
}