From 6b4267b50bff63b574d6fb993f7fcb9e4c5e1922 Mon Sep 17 00:00:00 2001 From: lukas Date: Sun, 25 Jul 2021 10:15:28 +0200 Subject: [PATCH] implement lukas/openmediacenter#72 --- apiGo/api/Video.go | 7 ++++++- src/pages/HomePage/HomePage.tsx | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apiGo/api/Video.go b/apiGo/api/Video.go index 69429e4..9e6c1d2 100644 --- a/apiGo/api/Video.go +++ b/apiGo/api/Video.go @@ -44,9 +44,11 @@ func getVideoHandlers() { likes = iota random = iota names = iota + length = iota ) - var SortClause string + // if wrong number passed no sorting is performed + var SortClause = "" switch args.Sort { case date: SortClause = "ORDER BY create_date DESC, movie_name" @@ -60,6 +62,9 @@ func getVideoHandlers() { case names: SortClause = "ORDER BY movie_name" break + case length: + SortClause = "ORDER BY length DESC" + break } var query string diff --git a/src/pages/HomePage/HomePage.tsx b/src/pages/HomePage/HomePage.tsx index aa9ee48..752e259 100644 --- a/src/pages/HomePage/HomePage.tsx +++ b/src/pages/HomePage/HomePage.tsx @@ -19,7 +19,8 @@ export enum SortBy { date, likes, random, - name + name, + length } interface Props extends RouteComponentProps {} @@ -189,6 +190,7 @@ export class HomePage extends React.Component { this.onDropDownItemClick(SortBy.likes, 'Most likes')}>Most likes this.onDropDownItemClick(SortBy.random, 'Random')}>Random this.onDropDownItemClick(SortBy.name, 'Name')}>Name + this.onDropDownItemClick(SortBy.length, 'Length')}>Length