add test and openapi for hot sort parameter

pull/3662/head
Rigel Kent 2021-01-28 14:43:02 +01:00 committed by Chocobozzz
parent ba5d4a849c
commit 923d3d5ad5
3 changed files with 12 additions and 1 deletions

View File

@ -262,7 +262,9 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
* justify a better score. However there are multiple ways to achieve that * justify a better score. However there are multiple ways to achieve that
* goal, which is left for later. Yes, this is a TODO :) * 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 * see https://github.com/reddit-archive/reddit/blob/master/r2/r2/lib/db/_sorts.pyx#L47-L58
*/ */
const weights = { const weights = {

View File

@ -355,6 +355,14 @@ describe('Test a single server', function () {
expect(videos.length).to.equal(2) 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 () { it('Should update a video', async function () {
const attributes = { const attributes = {
name: 'my super video updated', name: 'my super video updated',

View File

@ -3491,6 +3491,7 @@ components:
- -views - -views
- -likes - -likes
- -trending - -trending
- -hot
videosSearchSort: videosSearchSort:
name: sort name: sort
in: query in: query