]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
add test and openapi for hot sort parameter
authorRigel Kent <sendmemail@rigelk.eu>
Thu, 28 Jan 2021 13:43:02 +0000 (14:43 +0100)
committerChocobozzz <chocobozzz@cpy.re>
Thu, 28 Jan 2021 14:55:34 +0000 (15:55 +0100)
server/models/video/video-query-builder.ts
server/tests/api/videos/single-server.ts
support/doc/api/openapi.yaml

index 3f31ac86273e479c8cb9121880b34d1c6026ac37..e2145fb9a018338da4a8e5f5530d34cb07ba0c3d 100644 (file)
@@ -262,7 +262,9 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
        * justify a better score. However there are multiple ways to achieve that
        * goal, which is left for later. Yes, this is a TODO :)
        *
-       * note: weights and base score are in number of half-days.
+       * notes:
+       *  - weights and base score are in number of half-days.
+       *  - all comments are counted, regardless of being written by the video author or not
        * see https://github.com/reddit-archive/reddit/blob/master/r2/r2/lib/db/_sorts.pyx#L47-L58
        */
       const weights = {
index b74bc3e80912f6b49d27d3b09be5ddc28b89ca63..52c6800c1c590d146ca346ab3ce8e0f4d9a4afaa 100644 (file)
@@ -355,6 +355,14 @@ describe('Test a single server', function () {
     expect(videos.length).to.equal(2)
   })
 
+  it('Should list and sort by hotness in descending order', async function () {
+    const res = await getVideosListPagination(server.url, 0, 2, '-hot')
+
+    const videos = res.body.data
+    expect(res.body.total).to.equal(6)
+    expect(videos.length).to.equal(2)
+  })
+
   it('Should update a video', async function () {
     const attributes = {
       name: 'my super video updated',
index 8ad98a9a9a13933a510467e8ef552ef356490f32..b05a113cadcf9293dbaffe0b91ea2d4f1b2d4b11 100644 (file)
@@ -3491,6 +3491,7 @@ components:
         - -views
         - -likes
         - -trending
+        - -hot
     videosSearchSort:
       name: sort
       in: query