Keep displayName as valid playlist sort
This commit is contained in:
parent
15feebd97a
commit
49cff3a4c9
3 changed files with 16 additions and 5 deletions
|
@ -85,7 +85,7 @@ const SORTABLE_COLUMNS = {
|
|||
|
||||
USER_NOTIFICATIONS: [ 'createdAt', 'read' ],
|
||||
|
||||
VIDEO_PLAYLISTS: [ 'name', 'createdAt', 'updatedAt' ],
|
||||
VIDEO_PLAYLISTS: [ 'name', 'displayName', 'createdAt', 'updatedAt' ],
|
||||
|
||||
PLUGINS: [ 'name', 'createdAt', 'updatedAt' ],
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { literal, Op, OrderItem } from 'sequelize'
|
||||
import { Model, Sequelize } from 'sequelize-typescript'
|
||||
import validator from 'validator'
|
||||
import { Col } from 'sequelize/types/lib/utils'
|
||||
import { literal, OrderItem, Op } from 'sequelize'
|
||||
import validator from 'validator'
|
||||
|
||||
type SortType = { sortModel: string, sortValue: string }
|
||||
|
||||
|
@ -22,6 +22,16 @@ function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderIt
|
|||
return [ [ finalField, direction ], lastSort ]
|
||||
}
|
||||
|
||||
function getPlaylistSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
|
||||
const { direction, field } = buildDirectionAndField(value)
|
||||
|
||||
if (field.toLowerCase() === 'name') {
|
||||
return [ [ 'displayName', direction ], lastSort ]
|
||||
}
|
||||
|
||||
return getSort(value, lastSort)
|
||||
}
|
||||
|
||||
function getCommentSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
|
||||
const { direction, field } = buildDirectionAndField(value)
|
||||
|
||||
|
@ -227,6 +237,7 @@ export {
|
|||
buildBlockedAccountSQL,
|
||||
buildBlockedAccountSQLOptimized,
|
||||
buildLocalActorIdsIn,
|
||||
getPlaylistSort,
|
||||
SortType,
|
||||
buildLocalAccountIdsIn,
|
||||
getSort,
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
UpdatedAt
|
||||
} from 'sequelize-typescript'
|
||||
import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
|
||||
import { buildServerIdsFollowedBy, buildWhereIdOrUUID, getSort, isOutdated, throwIfNotValid } from '../utils'
|
||||
import { buildServerIdsFollowedBy, buildWhereIdOrUUID, getPlaylistSort, getPlaylistSort, isOutdated, throwIfNotValid } from '../utils'
|
||||
import {
|
||||
isVideoPlaylistDescriptionValid,
|
||||
isVideoPlaylistNameValid,
|
||||
|
@ -312,7 +312,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
|
|||
const query = {
|
||||
offset: options.start,
|
||||
limit: options.count,
|
||||
order: getSort(options.sort)
|
||||
order: getPlaylistSort(options.sort)
|
||||
}
|
||||
|
||||
const scopes: (string | ScopeOptions)[] = [
|
||||
|
|
Loading…
Reference in a new issue