@@ -83,6 +83,11 @@ const getManyByChannelBySeasonQuerySchema = Joi.object({
8383 page : Joi . number ( ) . integer ( ) . min ( 1 ) . required ( )
8484} ) ;
8585
86+ const getManyByChannelBySeasonShuffleQuerySchema = Joi . object ( {
87+ page : Joi . number ( ) . integer ( ) . min ( 1 ) . required ( ) ,
88+ shuffleHash : Joi . string ( ) . required ( )
89+ } ) ;
90+
8691const getManyByChannelTopQuerySchema = Joi . object ( {
8792 range : Joi . string ( ) . valid ( ...QUERY_PARAMS_STATS_RANGE_VALUES ) . required ( ) ,
8893 page : Joi . number ( ) . integer ( ) . min ( 1 ) . required ( )
@@ -566,6 +571,38 @@ export class ItemController {
566571 } ) ;
567572 }
568573
574+ static async getManyByChannelBySeasonShuffle ( req : Request , res : Response ) : Promise < void > {
575+ validateParamsObject ( getManyByChannelParmsSchema , req , res , async ( ) => {
576+ validateQueryObject ( getManyByChannelBySeasonShuffleQuerySchema , req , res , async ( ) => {
577+ try {
578+ const { page, limit, offset } = getPaginationParams ( req ) ;
579+ const { channelIdOrIdText } = req . params ;
580+ const { shuffleHash } = req . query as { shuffleHash : string } ;
581+
582+ const channel = await ItemController . channelService . getByIdOrIdText (
583+ channelIdOrIdText ,
584+ { channel_about : true }
585+ ) ;
586+
587+ if ( ! channel ) {
588+ res . status ( 404 ) . json ( { message : 'Channel not found' } ) ;
589+ return ;
590+ }
591+
592+ const config : FindManyOptions < Item > = {
593+ skip : offset ,
594+ take : limit
595+ } ;
596+ const items = await ItemController . itemService . getManyByChannelBySeason ( channel , "shuffle" , config , shuffleHash ) ;
597+
598+ res . json ( { data : items , meta : { page, count : channel . channel_about . episode_count , limit } } ) ;
599+ } catch ( error ) {
600+ handleGenericErrorResponse ( res , error ) ;
601+ }
602+ } ) ;
603+ } ) ;
604+ }
605+
569606 static async getManyForQueueByPubDate ( req : Request , res : Response ) : Promise < void > {
570607 validateParamsObject ( getManyForQueueByPubDateParamsSchema , req , res , async ( ) => {
571608 validateQueryObject ( getManyForQueueByPubDateQuerySchema , req , res , async ( ) => {
0 commit comments