-impl<'a> PrivateMessageReportQuery<'a> {
- pub fn list(self) -> Result<Vec<PrivateMessageReportView>, Error> {
- let (person_alias_1, person_alias_2) = diesel::alias!(person as person1, person as person2);
-
- let mut query = private_message_report::table
- .inner_join(private_message::table)
- .inner_join(person::table.on(private_message::creator_id.eq(person::id)))
- .inner_join(
- person_alias_1.on(private_message_report::creator_id.eq(person_alias_1.field(person::id))),
- )
- .left_join(
- person_alias_2
- .on(private_message_report::resolver_id.eq(person_alias_2.field(person::id).nullable())),
- )
- .select((
- private_message_report::all_columns,
- private_message::all_columns,
- Person::safe_columns_tuple(),
- person_alias_1.fields(Person::safe_columns_tuple()),
- person_alias_2
- .fields(Person::safe_columns_tuple())
- .nullable(),
- ))
- .into_boxed();
-
- if self.unresolved_only.unwrap_or(true) {
- query = query.filter(private_message_report::resolved.eq(false));
- }
-
- let (limit, offset) = limit_and_offset(self.page, self.limit)?;
-
- query = query
- .order_by(private_message::published.desc())
- .limit(limit)
- .offset(offset);
-
- let res = query.load::<PrivateMessageReportViewTuple>(self.conn)?;
-
- Ok(PrivateMessageReportView::from_tuple_to_vec(res))
+impl PrivateMessageReportQuery {
+ pub async fn list(self, pool: &mut DbPool<'_>) -> Result<Vec<PrivateMessageReportView>, Error> {
+ queries().list(pool, self).await