From b2290d030af07324cc22d9164c63992b8ff2129a Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 12 Oct 2020 22:28:09 -0700 Subject: [PATCH] Allow orderby bitrate. --- etiquette/constants.py | 1 + etiquette/searchhelpers.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/etiquette/constants.py b/etiquette/constants.py index 080e7c3..39aa22e 100644 --- a/etiquette/constants.py +++ b/etiquette/constants.py @@ -196,6 +196,7 @@ SQL_INDEX = sqlhelpers.reverse_table_column_map(SQL_COLUMNS) ALLOWED_ORDERBY_COLUMNS = [ 'extension', + 'bitrate', 'width', 'height', 'ratio', diff --git a/etiquette/searchhelpers.py b/etiquette/searchhelpers.py index 35bf8ac..9ef8877 100644 --- a/etiquette/searchhelpers.py +++ b/etiquette/searchhelpers.py @@ -335,10 +335,13 @@ def normalize_orderby(orderby, warning_bag=None): column = 'RANDOM()' elif column == 'area': - column = 'width * height' + column = '(width * height)' + + elif column == 'bitrate': + column = '((bytes / 128) / duration)' elif column == 'ratio': - column = 'width / height' + column = '(width / height)' if direction not in ('asc', 'desc'): message = constants.WARNING_ORDERBY_BADDIRECTION.format(