default ordering

This commit is contained in:
Simon
2025-06-08 06:45:47 +00:00
parent e87a2ed237
commit f4f22572c1

View File

@@ -198,8 +198,14 @@ impl HanimeProvider {
async fn get(&self, cache: VideoCache, pool: DbPool, page: u8, query: String, sort:String) -> Result<Vec<VideoItem>> { async fn get(&self, cache: VideoCache, pool: DbPool, page: u8, query: String, sort:String) -> Result<Vec<VideoItem>> {
let index = format!("{}:{}:{}", query, page, sort); let index = format!("{}:{}:{}", query, page, sort);
let order_by = sort.split(".").collect::<Vec<&str>>()[0].to_string(); let order_by = match sort.contains("."){
let ordering = sort.split(".").collect::<Vec<&str>>()[1].to_string(); true => sort.split(".").collect::<Vec<&str>>()[0].to_string(),
false => "created_at_unix".to_string(),
};
let ordering = match sort.contains("."){
true => sort.split(".").collect::<Vec<&str>>()[1].to_string(),
false => "desc".to_string(),
};
let old_items = match cache.get(&index) { let old_items = match cache.get(&index) {
Some((time, items)) => { Some((time, items)) => {
if time.elapsed().unwrap_or_default().as_secs() < 60 * 60 * 12 { if time.elapsed().unwrap_or_default().as_secs() < 60 * 60 * 12 {