mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-24 13:21:19 +00:00
15930cbf4d
* Update utils.rs * Update traits.rs * Update comment_report_view.rs * Update comment_view.rs * Update local_user_view.rs * Update post_report_view.rs * Update post_view.rs * Update private_message_report_view.rs * Update private_message_view.rs * Update registration_application_view.rs * Update site_view.rs * Update structs.rs * Update comment_reply_view.rs * Update community_block_view.rs * Update community_follower_view.rs * Update community_moderator_view.rs * Update community_person_ban_view.rs * Update community_person_ban_view.rs * Update community_view.rs * Update person_block_view.rs * Update person_mention_view.rs * Update person_view.rs * Update structs.rs * Update admin_purge_comment_view.rs * Update admin_purge_community_view.rs * Update admin_purge_person_view.rs * Update admin_purge_post_view.rs * Update mod_add_community_view.rs * Update mod_add_view.rs * Update mod_ban_from_community_view.rs * Update mod_ban_view.rs * Update mod_feature_post_view.rs * Update mod_hide_community_view.rs * Update mod_lock_post_view.rs * Update mod_remove_comment_view.rs * Update mod_remove_community_view.rs * Update mod_remove_post_view.rs * Update mod_transfer_community_view.rs * Update structs.rs * Update utils.rs * Update private_message_view.rs * Update comment_report_view.rs * Update registration_application_view.rs * Update utils.rs * fix * fix db_views * fix * Update comment_view.rs
30 lines
888 B
Rust
30 lines
888 B
Rust
use crate::structs::SiteView;
|
|
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, QueryDsl};
|
|
use diesel_async::RunQueryDsl;
|
|
use lemmy_db_schema::{
|
|
schema::{local_site, local_site_rate_limit, site, site_aggregates},
|
|
utils::{get_conn, DbPool},
|
|
};
|
|
|
|
impl SiteView {
|
|
pub async fn read_local(pool: &mut DbPool<'_>) -> Result<Self, Error> {
|
|
let conn = &mut get_conn(pool).await?;
|
|
let mut res = site::table
|
|
.inner_join(local_site::table)
|
|
.inner_join(
|
|
local_site_rate_limit::table.on(local_site::id.eq(local_site_rate_limit::local_site_id)),
|
|
)
|
|
.inner_join(site_aggregates::table)
|
|
.select((
|
|
site::all_columns,
|
|
local_site::all_columns,
|
|
local_site_rate_limit::all_columns,
|
|
site_aggregates::all_columns,
|
|
))
|
|
.first::<SiteView>(conn)
|
|
.await?;
|
|
|
|
res.site.private_key = None;
|
|
Ok(res)
|
|
}
|
|
}
|