Rewrite video list in raw SQL
This commit is contained in:
parent
f8cce49c3f
commit
5f3e2425f1
3 changed files with 428 additions and 434 deletions
|
@ -156,8 +156,11 @@ function parseAggregateResult (result: any) {
|
|||
}
|
||||
|
||||
const createSafeIn = (model: typeof Model, stringArr: (string | number)[]) => {
|
||||
return stringArr.map(t => model.sequelize.escape('' + t))
|
||||
.join(', ')
|
||||
return stringArr.map(t => {
|
||||
return t === null
|
||||
? null
|
||||
: model.sequelize.escape('' + t)
|
||||
}).join(', ')
|
||||
}
|
||||
|
||||
function buildLocalAccountIdsIn () {
|
||||
|
@ -172,6 +175,21 @@ function buildLocalActorIdsIn () {
|
|||
)
|
||||
}
|
||||
|
||||
function buildDirectionAndField (value: string) {
|
||||
let field: string
|
||||
let direction: 'ASC' | 'DESC'
|
||||
|
||||
if (value.substring(0, 1) === '-') {
|
||||
direction = 'DESC'
|
||||
field = value.substring(1)
|
||||
} else {
|
||||
direction = 'ASC'
|
||||
field = value
|
||||
}
|
||||
|
||||
return { direction, field }
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
|
@ -191,6 +209,7 @@ export {
|
|||
isOutdated,
|
||||
parseAggregateResult,
|
||||
getFollowsSort,
|
||||
buildDirectionAndField,
|
||||
createSafeIn
|
||||
}
|
||||
|
||||
|
@ -203,18 +222,3 @@ function searchTrigramNormalizeValue (value: string) {
|
|||
function searchTrigramNormalizeCol (col: string) {
|
||||
return Sequelize.fn('lower', Sequelize.fn('immutable_unaccent', Sequelize.col(col)))
|
||||
}
|
||||
|
||||
function buildDirectionAndField (value: string) {
|
||||
let field: string
|
||||
let direction: 'ASC' | 'DESC'
|
||||
|
||||
if (value.substring(0, 1) === '-') {
|
||||
direction = 'DESC'
|
||||
field = value.substring(1)
|
||||
} else {
|
||||
direction = 'ASC'
|
||||
field = value
|
||||
}
|
||||
|
||||
return { direction, field }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue