Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Framasoft
PeerTube
PeerTube
Commits
eba2a7a8
Verified
Commit
eba2a7a8
authored
Jan 12, 2023
by
Chocobozzz
Browse files
Don't need a special comment sort function
parent
0b96a0fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/models/shared/sort.ts
View file @
eba2a7a8
...
...
@@ -44,19 +44,6 @@ function getPlaylistSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]):
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
[]
{
const
{
direction
,
field
}
=
buildSortDirectionAndField
(
value
)
...
...
@@ -151,7 +138,6 @@ export {
buildSortDirectionAndField
,
getPlaylistSort
,
getSort
,
getCommentSort
,
getAdminUsersSort
,
getVideoSort
,
getBlacklistSort
,
...
...
server/models/video/sql/comment/video-comment-list-query-builder.ts
View file @
eba2a7a8
import
{
Model
,
Sequelize
,
Transaction
}
from
'
sequelize
'
import
{
AbstractRunQuery
,
ModelBuilder
}
from
'
@server/models/shared
'
import
{
ActorImageType
,
VideoPrivacy
}
from
'
@shared/models
'
import
{
createSafeIn
,
get
Comment
Sort
,
parseRowCountResult
}
from
'
../../../shared
'
import
{
createSafeIn
,
getSort
,
parseRowCountResult
}
from
'
../../../shared
'
import
{
VideoCommentTableAttributes
}
from
'
./video-comment-table-attributes
'
export
interface
ListVideoCommentsOptions
{
...
...
@@ -384,7 +384,7 @@ export class VideoCommentListQueryBuilder extends AbstractRunQuery {
private
getOrder
()
{
if
(
!
this
.
options
.
sort
)
return
''
const
orders
=
get
Comment
Sort
(
this
.
options
.
sort
)
const
orders
=
getSort
(
this
.
options
.
sort
)
return
'
ORDER BY
'
+
orders
.
map
(
o
=>
`"
${
o
[
0
]}
"
${
o
[
1
]}
`
).
join
(
'
,
'
)
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment