Procházet zdrojové kódy

handle unlisted videos for top 10 (#35)

Rafał Pawłow před 2 roky
rodič
revize
0e9a6cf7fe

+ 4 - 4
src/resolvers/queryNodeStitchingResolvers/videoResolvers.ts

@@ -9,16 +9,16 @@ import { OrionContext } from '../../types'
 export const videoResolvers = (queryNodeSchema: GraphQLSchema): IResolvers<any, OrionContext> => ({
   Query: {
     top10VideosThisWeek: async (parent, args, context, info) => {
-      const mostViewedVideosIds = getMostViewedVideosIds(context, { limit: 10, period: 7 })
+      const mostViewedVideosIds = getMostViewedVideosIds(context, { limit: 30, period: 7 })
       const resolver = createResolver(queryNodeSchema, 'videos')
       const videos = await getDataWithIds(resolver, mostViewedVideosIds, parent, args, context, info)
-      return sortEntities(videos, mostViewedVideosIds)
+      return sortEntities(videos, mostViewedVideosIds).slice(0, 10)
     },
     top10VideosThisMonth: async (parent, args, context, info) => {
-      const mostViewedVideosIds = getMostViewedVideosIds(context, { limit: 10, period: 30 })
+      const mostViewedVideosIds = getMostViewedVideosIds(context, { limit: 30, period: 30 })
       const resolver = createResolver(queryNodeSchema, 'videos')
       const videos = await getDataWithIds(resolver, mostViewedVideosIds, parent, args, context, info)
-      return sortEntities(videos, mostViewedVideosIds)
+      return sortEntities(videos, mostViewedVideosIds).slice(0, 10)
     },
     mostViewedVideosConnection: async (parent, args, context, info) => {
       const mostViewedVideosIds = getMostViewedVideosIds(context, {

+ 4 - 2
tests/follows.test.ts

@@ -17,8 +17,10 @@ import { ChannelFollowsInfo } from '../src/entities/ChannelFollowsInfo'
 import { createMutationFn, createQueryFn, MutationFn, QueryFn } from './helpers'
 import { ChannelEventModel } from '../src/models/ChannelEvent'
 
-const FIRST_CHANNEL_ID = '6'
-const SECOND_CHANNEL_ID = '7'
+jest.setTimeout(20000)
+
+const FIRST_CHANNEL_ID = '1'
+const SECOND_CHANNEL_ID = '2'
 
 describe('Channel follows resolver', () => {
   let server: ApolloServer

+ 6 - 4
tests/views.test.ts

@@ -23,10 +23,12 @@ import { EntityViewsInfo } from '../src/entities/EntityViewsInfo'
 import { VideoEventModel } from '../src/models/VideoEvent'
 import { createMutationFn, createQueryFn, MutationFn, QueryFn } from './helpers'
 
-const FIRST_VIDEO_ID = '7'
-const SECOND_VIDEO_ID = '8'
-const FIRST_CHANNEL_ID = '6'
-const SECOND_CHANNEL_ID = '7'
+jest.setTimeout(20000)
+
+const FIRST_VIDEO_ID = '1'
+const SECOND_VIDEO_ID = '2'
+const FIRST_CHANNEL_ID = '2'
+const SECOND_CHANNEL_ID = '3'
 const FIRST_CATEGORY_ID = '1'
 
 describe('Video and channel views resolver', () => {