2022-05-03 17:44:13 +00:00
|
|
|
use crate::structs::SiteView;
|
2020-12-02 19:32:47 +00:00
|
|
|
use diesel::{result::Error, *};
|
2020-12-18 18:38:32 +00:00
|
|
|
use lemmy_db_schema::{
|
2022-05-03 17:44:13 +00:00
|
|
|
aggregates::structs::SiteAggregates,
|
2022-01-26 17:57:16 +00:00
|
|
|
schema::{site, site_aggregates},
|
|
|
|
source::site::Site,
|
2020-12-02 19:32:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
impl SiteView {
|
2022-03-08 12:52:33 +00:00
|
|
|
pub fn read_local(conn: &PgConnection) -> Result<Self, Error> {
|
2022-02-07 19:23:12 +00:00
|
|
|
let (mut site, counts) = site::table
|
2020-12-20 01:10:47 +00:00
|
|
|
.inner_join(site_aggregates::table)
|
2022-01-26 17:57:16 +00:00
|
|
|
.select((site::all_columns, site_aggregates::all_columns))
|
2022-03-08 12:52:33 +00:00
|
|
|
.order_by(site::id)
|
2022-01-26 17:57:16 +00:00
|
|
|
.first::<(Site, SiteAggregates)>(conn)?;
|
2020-12-02 19:32:47 +00:00
|
|
|
|
2022-02-07 19:23:12 +00:00
|
|
|
site.private_key = None;
|
2022-01-26 17:57:16 +00:00
|
|
|
Ok(SiteView { site, counts })
|
2020-12-02 19:32:47 +00:00
|
|
|
}
|
|
|
|
}
|