-impl<'a> RegistrationApplicationQuery<'a> {
- pub fn list(self) -> Result<Vec<RegistrationApplicationView>, Error> {
- let person_alias_1 = diesel::alias!(person as person1);
-
- let mut query = registration_application::table
- .inner_join(local_user::table.on(registration_application::local_user_id.eq(local_user::id)))
- .inner_join(person::table.on(local_user::person_id.eq(person::id)))
- .left_join(
- person_alias_1
- .on(registration_application::admin_id.eq(person_alias_1.field(person::id).nullable())),
- )
- .order_by(registration_application::published.desc())
- .select((
- registration_application::all_columns,
- LocalUser::safe_settings_columns_tuple(),
- Person::safe_columns_tuple(),
- person_alias_1
- .fields(Person::safe_columns_tuple())
- .nullable(),
- ))
- .into_boxed();
-
- if self.unread_only.unwrap_or(false) {
- query = query.filter(registration_application::admin_id.is_null())
- }
-
- if self.verified_email_only.unwrap_or(false) {
- query = query.filter(local_user::email_verified.eq(true))
- }
-
- let (limit, offset) = limit_and_offset(self.page, self.limit)?;
-
- query = query
- .limit(limit)
- .offset(offset)
- .order_by(registration_application::published.desc());
-
- let res = query.load::<RegistrationApplicationViewTuple>(self.conn)?;
-
- Ok(RegistrationApplicationView::from_tuple_to_vec(res))
+impl RegistrationApplicationQuery {
+ pub async fn list(
+ self,
+ pool: &mut DbPool<'_>,
+ ) -> Result<Vec<RegistrationApplicationView>, Error> {
+ queries().list(pool, self).await