mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-12 02:19:21 +00:00
Update custom_emoji_view
Only keep get_all als helper function calling list with paging ignored Only order on category when filtering on category
This commit is contained in:
parent
1f629cc02d
commit
4771085253
|
@ -36,21 +36,7 @@ impl CustomEmojiView {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_all(pool: &mut DbPool<'_>) -> Result<Vec<Self>, Error> {
|
pub async fn get_all(pool: &mut DbPool<'_>) -> Result<Vec<Self>, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
Self::list(pool, &None, None, None, true).await
|
||||||
let emojis = custom_emoji::table
|
|
||||||
.left_join(
|
|
||||||
custom_emoji_keyword::table.on(custom_emoji_keyword::custom_emoji_id.eq(custom_emoji::id)),
|
|
||||||
)
|
|
||||||
.order(custom_emoji::category)
|
|
||||||
.then_order_by(custom_emoji::id)
|
|
||||||
.select((
|
|
||||||
custom_emoji::all_columns,
|
|
||||||
custom_emoji_keyword::all_columns.nullable(), // (or all the columns if you want)
|
|
||||||
))
|
|
||||||
.load::<CustomEmojiTuple>(conn)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(CustomEmojiView::from_tuple_to_vec(emojis))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list(
|
pub async fn list(
|
||||||
|
@ -74,12 +60,14 @@ impl CustomEmojiView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(category) = category {
|
if let Some(category) = category {
|
||||||
query = query.filter(custom_emoji::category.eq(category))
|
query = query
|
||||||
|
.filter(custom_emoji::category.eq(category))
|
||||||
|
.order(custom_emoji::category)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = query.then_order_by(custom_emoji::id);
|
||||||
|
|
||||||
let emojis = query
|
let emojis = query
|
||||||
.order(custom_emoji::category)
|
|
||||||
.then_order_by(custom_emoji::id)
|
|
||||||
.select((
|
.select((
|
||||||
custom_emoji::all_columns,
|
custom_emoji::all_columns,
|
||||||
custom_emoji_keyword::all_columns.nullable(), // (or all the columns if you want)
|
custom_emoji_keyword::all_columns.nullable(), // (or all the columns if you want)
|
||||||
|
|
Loading…
Reference in a new issue