)
}
- fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error> {
+ fn read_from_name(
+ conn: &PgConnection,
+ community_name: &str,
+ include_deleted: bool,
+ ) -> Result<Community, Error> {
use crate::schema::community::dsl::*;
- community
+ let mut q = community
+ .into_boxed()
.filter(local.eq(true))
- .filter(lower(name).eq(lower(community_name)))
- .first::<Self>(conn)
+ .filter(lower(name).eq(lower(community_name)));
+ if !include_deleted {
+ q = q.filter(deleted.eq(false)).filter(removed.eq(false));
+ }
+ q.first::<Self>(conn)
}
fn read_from_name_and_domain(