This commit is contained in:
lukas 2021-07-25 10:15:28 +02:00
parent ebb55eb0dc
commit 6b4267b50b
2 changed files with 9 additions and 2 deletions

View File

@ -44,9 +44,11 @@ func getVideoHandlers() {
likes = iota likes = iota
random = iota random = iota
names = iota names = iota
length = iota
) )
var SortClause string // if wrong number passed no sorting is performed
var SortClause = ""
switch args.Sort { switch args.Sort {
case date: case date:
SortClause = "ORDER BY create_date DESC, movie_name" SortClause = "ORDER BY create_date DESC, movie_name"
@ -60,6 +62,9 @@ func getVideoHandlers() {
case names: case names:
SortClause = "ORDER BY movie_name" SortClause = "ORDER BY movie_name"
break break
case length:
SortClause = "ORDER BY length DESC"
break
} }
var query string var query string

View File

@ -19,7 +19,8 @@ export enum SortBy {
date, date,
likes, likes,
random, random,
name name,
length
} }
interface Props extends RouteComponentProps {} interface Props extends RouteComponentProps {}
@ -189,6 +190,7 @@ export class HomePage extends React.Component<Props, state> {
<span onClick={(): void => this.onDropDownItemClick(SortBy.likes, 'Most likes')}>Most likes</span> <span onClick={(): void => this.onDropDownItemClick(SortBy.likes, 'Most likes')}>Most likes</span>
<span onClick={(): void => this.onDropDownItemClick(SortBy.random, 'Random')}>Random</span> <span onClick={(): void => this.onDropDownItemClick(SortBy.random, 'Random')}>Random</span>
<span onClick={(): void => this.onDropDownItemClick(SortBy.name, 'Name')}>Name</span> <span onClick={(): void => this.onDropDownItemClick(SortBy.name, 'Name')}>Name</span>
<span onClick={(): void => this.onDropDownItemClick(SortBy.length, 'Length')}>Length</span>
</div> </div>
</div> </div>
</div> </div>