aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-01-12 11:19:42 +0100
committerChocobozzz <me@florianbigard.com>2023-01-12 11:19:42 +0100
commiteba2a7a834c4ef5a409e80021faad54ceef4e6d8 (patch)
treee8d65c930292b92dc2bf68ddf7bbc3994b7fbd9b /server/models
parent0b96a0fb77cee07abac185fb1fb704388498631b (diff)
downloadPeerTube-eba2a7a834c4ef5a409e80021faad54ceef4e6d8.tar.gz
PeerTube-eba2a7a834c4ef5a409e80021faad54ceef4e6d8.tar.zst
PeerTube-eba2a7a834c4ef5a409e80021faad54ceef4e6d8.zip
Don't need a special comment sort function
Diffstat (limited to 'server/models')
-rw-r--r--server/models/shared/sort.ts14
-rw-r--r--server/models/video/sql/comment/video-comment-list-query-builder.ts4
2 files changed, 2 insertions, 16 deletions
diff --git a/server/models/shared/sort.ts b/server/models/shared/sort.ts
index a9a093099..d923072f2 100644
--- a/server/models/shared/sort.ts
+++ b/server/models/shared/sort.ts
@@ -44,19 +44,6 @@ function getPlaylistSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]):
44 return getSort(value, lastSort) 44 return getSort(value, lastSort)
45} 45}
46 46
47function getCommentSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
48 const { direction, field } = buildSortDirectionAndField(value)
49
50 if (field === 'totalReplies') {
51 return [
52 [ 'totalReplies', direction ],
53 lastSort
54 ]
55 }
56
57 return getSort(value, lastSort)
58}
59
60function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { 47function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
61 const { direction, field } = buildSortDirectionAndField(value) 48 const { direction, field } = buildSortDirectionAndField(value)
62 49
@@ -151,7 +138,6 @@ export {
151 buildSortDirectionAndField, 138 buildSortDirectionAndField,
152 getPlaylistSort, 139 getPlaylistSort,
153 getSort, 140 getSort,
154 getCommentSort,
155 getAdminUsersSort, 141 getAdminUsersSort,
156 getVideoSort, 142 getVideoSort,
157 getBlacklistSort, 143 getBlacklistSort,
diff --git a/server/models/video/sql/comment/video-comment-list-query-builder.ts b/server/models/video/sql/comment/video-comment-list-query-builder.ts
index 6d752d4a4..a7eed22a1 100644
--- a/server/models/video/sql/comment/video-comment-list-query-builder.ts
+++ b/server/models/video/sql/comment/video-comment-list-query-builder.ts
@@ -1,7 +1,7 @@
1import { Model, Sequelize, Transaction } from 'sequelize' 1import { Model, Sequelize, Transaction } from 'sequelize'
2import { AbstractRunQuery, ModelBuilder } from '@server/models/shared' 2import { AbstractRunQuery, ModelBuilder } from '@server/models/shared'
3import { ActorImageType, VideoPrivacy } from '@shared/models' 3import { ActorImageType, VideoPrivacy } from '@shared/models'
4import { createSafeIn, getCommentSort, parseRowCountResult } from '../../../shared' 4import { createSafeIn, getSort, parseRowCountResult } from '../../../shared'
5import { VideoCommentTableAttributes } from './video-comment-table-attributes' 5import { VideoCommentTableAttributes } from './video-comment-table-attributes'
6 6
7export interface ListVideoCommentsOptions { 7export interface ListVideoCommentsOptions {
@@ -384,7 +384,7 @@ export class VideoCommentListQueryBuilder extends AbstractRunQuery {
384 private getOrder () { 384 private getOrder () {
385 if (!this.options.sort) return '' 385 if (!this.options.sort) return ''
386 386
387 const orders = getCommentSort(this.options.sort) 387 const orders = getSort(this.options.sort)
388 388
389 return 'ORDER BY ' + orders.map(o => `"${o[0]}" ${o[1]}`).join(', ') 389 return 'ORDER BY ' + orders.map(o => `"${o[0]}" ${o[1]}`).join(', ')
390 } 390 }