Skip to content

Commit

Permalink
issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nyzd committed Jan 27, 2024
1 parent f5ed0ce commit 5fa533e
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/models_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,31 +223,26 @@ impl Filter for Translation {

let mut _query = translations_table.into_boxed();

match filters.sort() {
_query = match filters.sort() {
Some(sort_str) => match sort_str.as_str() {
"createTime" => match filters.order().unwrap_or_default() {
Order::Asc => {
_query = translations.order(created_at.asc()).internal_into_boxed()
}
Order::Desc => {
_query = translations.order(created_at.desc()).internal_into_boxed()
}
Order::Asc =>
Ok(translations.order(created_at.asc()).internal_into_boxed()),
Order::Desc =>
Ok(translations.order(created_at.desc()).internal_into_boxed())
},

"updateTime" => match filters.order().unwrap_or_default() {
Order::Asc => {
_query = translations.order(updated_at.asc()).internal_into_boxed()
}
Order::Desc => {
_query = translations.order(updated_at.desc()).internal_into_boxed()
}
Order::Asc =>
Ok(translations.order(updated_at.asc()).internal_into_boxed()),
Order::Desc =>
Ok(translations.order(updated_at.desc()).internal_into_boxed())
},

"language" => match filters.order().unwrap_or_default() {
Order::Asc => _query = translations.order(language.asc()).internal_into_boxed(),
Order::Desc => {
_query = translations.order(language.desc()).internal_into_boxed()
}
Order::Asc => Ok(translations.order(language.asc()).internal_into_boxed()),
Order::Desc =>
Ok(translations.order(language.desc()).internal_into_boxed())
},

//"mushaf" => match filters.order().unwrap_or_default() {
Expand All @@ -270,16 +265,15 @@ impl Filter for Translation {
// }
//},

value => {
return Err(RouterError::BadRequest(format!(
value =>
Err(RouterError::BadRequest(format!(
"Sort value {} is not possible!",
value
)))
}
},

None => {}
};
None => Ok(translations.into_boxed())
}?;

_query = match filters.to() {
Some(limit) => _query
Expand Down

0 comments on commit 5fa533e

Please sign in to comment.