diff options
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r-- | server/models/utils.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts index 24890f961..e7e6ddde1 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { Model, Sequelize } from 'sequelize-typescript' | 1 | import { Model, Sequelize } from 'sequelize-typescript' |
2 | import * as validator from 'validator' | 2 | import * as validator from 'validator' |
3 | import { Col } from 'sequelize/types/lib/utils' | 3 | import { Col } from 'sequelize/types/lib/utils' |
4 | import { OrderItem, literal } from 'sequelize' | 4 | import { col, literal, OrderItem } from 'sequelize' |
5 | 5 | ||
6 | type SortType = { sortModel: any, sortValue: string } | 6 | type SortType = { sortModel: string, sortValue: string } |
7 | 7 | ||
8 | // Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ] | 8 | // Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ] |
9 | function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { | 9 | function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { |
@@ -51,10 +51,10 @@ function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): Or | |||
51 | return [ firstSort, lastSort ] | 51 | return [ firstSort, lastSort ] |
52 | } | 52 | } |
53 | 53 | ||
54 | function getSortOnModel (model: any, value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { | 54 | function getBlacklistSort (model: any, value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { |
55 | const [ firstSort ] = getSort(value) | 55 | const [ firstSort ] = getSort(value) |
56 | 56 | ||
57 | if (model) return [ [ model, firstSort[0], firstSort[1] ], lastSort ] | 57 | if (model) return [ [ literal(`"${model}.${firstSort[ 0 ]}" ${firstSort[ 1 ]}`) ], lastSort ] as any[] // FIXME: typings |
58 | return [ firstSort, lastSort ] | 58 | return [ firstSort, lastSort ] |
59 | } | 59 | } |
60 | 60 | ||
@@ -155,7 +155,7 @@ export { | |||
155 | buildLocalAccountIdsIn, | 155 | buildLocalAccountIdsIn, |
156 | getSort, | 156 | getSort, |
157 | getVideoSort, | 157 | getVideoSort, |
158 | getSortOnModel, | 158 | getBlacklistSort, |
159 | createSimilarityAttribute, | 159 | createSimilarityAttribute, |
160 | throwIfNotValid, | 160 | throwIfNotValid, |
161 | buildServerIdsFollowedBy, | 161 | buildServerIdsFollowedBy, |