Skip to content

Commit

Permalink
Nothing changed
Browse files Browse the repository at this point in the history
  • Loading branch information
nyzd committed Jan 27, 2024
1 parent 310b60f commit f5ed0ce
Showing 1 changed file with 54 additions and 29 deletions.
83 changes: 54 additions & 29 deletions src/models_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,38 +223,63 @@ impl Filter for Translation {

let mut _query = translations_table.into_boxed();

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

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

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

// TODO: This is not working the way we want
// must order the mushaf by mushaf_name
"mushaf" => Ok(match filters.order().unwrap_or_default() {
Order::Asc => translations.order(mushaf_id.asc()).internal_into_boxed(),
Order::Desc => translations.order(mushaf_id.desc()).internal_into_boxed(),
}),

value => Err(RouterError::BadRequest(format!(
"Sort value {} is not possible!",
value
))),
"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()
}
},

"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()
}
},

"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()
}
},

//"mushaf" => match filters.order().unwrap_or_default() {
// Order::Asc => {
// is_mushaf_sort = true;
// _query_with_mushaf = translations
// .select(Translation::as_select())
// .inner_join(mushafs)
// .order(name.asc())
// .internal_into_boxed()
// }

// Order::Desc => {
// is_mushaf_sort = true;
// _query_with_mushaf = translations
// .select(Translation::as_select())
// .inner_join(mushafs)
// .order(name.desc())
// .internal_into_boxed()
// }
//},

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

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

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

0 comments on commit f5ed0ce

Please sign in to comment.