@@ -2,8 +2,9 @@ import { MediumEnum } from 'podverse-helpers';
22import { StatsAggregatedItem } from '@orm/entities/stats/statsAggregatedItem' ;
33import { StatsTrackEventItemService } from './statsTrackEventItem' ;
44import { BaseStatsAggregatedService , UpdateHistoricalOptions } from './baseStatsAggregated' ;
5- import { FindManyOptions , IsNull , Not } from 'typeorm' ;
5+ import { Equal , FindManyOptions , IsNull , Not } from 'typeorm' ;
66import { getActiveFeedWhere } from '@orm/lib/feedFlagHelpers' ;
7+ import { getLiveItemStatusEnumValue } from '@orm/index' ;
78
89export class StatsAggregatedItemService extends BaseStatsAggregatedService < StatsAggregatedItem , number > {
910 private statsTrackEventItemService : StatsTrackEventItemService ;
@@ -21,8 +22,11 @@ export class StatsAggregatedItemService extends BaseStatsAggregatedService<Stats
2122 config : FindManyOptions < StatsAggregatedItem > ,
2223 medium_id : MediumEnum | null ,
2324 category_id : number | null ,
24- itemType : 'normal' | 'live-item'
25+ itemType : 'normal' | 'live-item' ,
26+ liveItemType : 'pending' | 'live' | 'ended' | null
2527 ) : Promise < StatsAggregatedItem [ ] > {
28+ const live_item_status_id = getLiveItemStatusEnumValue ( liveItemType ) ;
29+
2630 return this . repositoryRead . find ( {
2731 where : {
2832 item : {
@@ -32,7 +36,9 @@ export class StatsAggregatedItemService extends BaseStatsAggregatedService<Stats
3236 category_id
3337 } ) ,
3438 live_item : {
35- id : itemType === 'live-item' ? Not ( IsNull ( ) ) : IsNull ( )
39+ id : itemType === 'live-item' ? Not ( IsNull ( ) ) : IsNull ( ) ,
40+ ...( live_item_status_id ? { live_item_status_id : Equal ( live_item_status_id ) } : { } )
41+
3642 }
3743 }
3844 } ,
@@ -43,8 +49,11 @@ export class StatsAggregatedItemService extends BaseStatsAggregatedService<Stats
4349 async getManyByChannelsAndCount (
4450 config : FindManyOptions < StatsAggregatedItem > ,
4551 channel_ids : number [ ] ,
46- itemType : 'normal' | 'live-item'
52+ itemType : 'normal' | 'live-item' ,
53+ liveItemType : 'pending' | 'live' | 'ended' | null
4754 ) : Promise < [ StatsAggregatedItem [ ] , number ] > {
55+ const live_item_status_id = getLiveItemStatusEnumValue ( liveItemType ) ;
56+
4857 return this . repositoryRead . findAndCount ( {
4958 where : {
5059 item : {
@@ -54,7 +63,8 @@ export class StatsAggregatedItemService extends BaseStatsAggregatedService<Stats
5463 category_id : null
5564 } ) ,
5665 live_item : {
57- id : itemType === 'live-item' ? Not ( IsNull ( ) ) : IsNull ( )
66+ id : itemType === 'live-item' ? Not ( IsNull ( ) ) : IsNull ( ) ,
67+ ...( live_item_status_id ? { live_item_status_id : Equal ( live_item_status_id ) } : { } )
5868 }
5969 }
6070 } ,
0 commit comments