Don't need a special comment sort function
This commit is contained in:
parent
0b96a0fb77
commit
eba2a7a834
|
@ -44,19 +44,6 @@ function getPlaylistSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]):
|
||||||
return getSort(value, lastSort)
|
return getSort(value, lastSort)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCommentSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
|
|
||||||
const { direction, field } = buildSortDirectionAndField(value)
|
|
||||||
|
|
||||||
if (field === 'totalReplies') {
|
|
||||||
return [
|
|
||||||
[ 'totalReplies', direction ],
|
|
||||||
lastSort
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
return getSort(value, lastSort)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
|
function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
|
||||||
const { direction, field } = buildSortDirectionAndField(value)
|
const { direction, field } = buildSortDirectionAndField(value)
|
||||||
|
|
||||||
|
@ -151,7 +138,6 @@ export {
|
||||||
buildSortDirectionAndField,
|
buildSortDirectionAndField,
|
||||||
getPlaylistSort,
|
getPlaylistSort,
|
||||||
getSort,
|
getSort,
|
||||||
getCommentSort,
|
|
||||||
getAdminUsersSort,
|
getAdminUsersSort,
|
||||||
getVideoSort,
|
getVideoSort,
|
||||||
getBlacklistSort,
|
getBlacklistSort,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Model, Sequelize, Transaction } from 'sequelize'
|
import { Model, Sequelize, Transaction } from 'sequelize'
|
||||||
import { AbstractRunQuery, ModelBuilder } from '@server/models/shared'
|
import { AbstractRunQuery, ModelBuilder } from '@server/models/shared'
|
||||||
import { ActorImageType, VideoPrivacy } from '@shared/models'
|
import { ActorImageType, VideoPrivacy } from '@shared/models'
|
||||||
import { createSafeIn, getCommentSort, parseRowCountResult } from '../../../shared'
|
import { createSafeIn, getSort, parseRowCountResult } from '../../../shared'
|
||||||
import { VideoCommentTableAttributes } from './video-comment-table-attributes'
|
import { VideoCommentTableAttributes } from './video-comment-table-attributes'
|
||||||
|
|
||||||
export interface ListVideoCommentsOptions {
|
export interface ListVideoCommentsOptions {
|
||||||
|
@ -384,7 +384,7 @@ export class VideoCommentListQueryBuilder extends AbstractRunQuery {
|
||||||
private getOrder () {
|
private getOrder () {
|
||||||
if (!this.options.sort) return ''
|
if (!this.options.sort) return ''
|
||||||
|
|
||||||
const orders = getCommentSort(this.options.sort)
|
const orders = getSort(this.options.sort)
|
||||||
|
|
||||||
return 'ORDER BY ' + orders.map(o => `"${o[0]}" ${o[1]}`).join(', ')
|
return 'ORDER BY ' + orders.map(o => `"${o[0]}" ${o[1]}`).join(', ')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue