podverse-orm 5.1.7-alpha.0 → 5.1.8-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelSeason.d.ts","sourceRoot":"","sources":["../../../src/services/channel/channelSeason.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channelSeason.d.ts","sourceRoot":"","sources":["../../../src/services/channel/channelSeason.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,KAAK,gBAAgB,GAAG;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AAE9D,qBAAa,oBAAqB,SAAQ,eAAe,CAAC,aAAa,EAAE,SAAS,CAAC;;IAK3E,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAWpE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAKvE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAKhF,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAGjD"}
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ChannelSeasonService = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
13
14
|
const channelSeason_1 = require("@orm/entities/channel/channelSeason");
|
|
14
15
|
const baseManyService_1 = require("@orm/services/base/baseManyService");
|
|
15
16
|
class ChannelSeasonService extends baseManyService_1.BaseManyService {
|
|
@@ -19,7 +20,7 @@ class ChannelSeasonService extends baseManyService_1.BaseManyService {
|
|
|
19
20
|
getChannelSeasonIndex(channel) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
const channelSeasonIndex = {};
|
|
22
|
-
const channel_seasons = yield this.repositoryRead.find({ where: { channel } });
|
|
23
|
+
const channel_seasons = yield this.repositoryRead.find({ where: { channel_id: (0, typeorm_1.Equal)(channel.id) } });
|
|
23
24
|
for (const channel_season of channel_seasons) {
|
|
24
25
|
channelSeasonIndex[channel_season.number] = channel_season;
|
|
25
26
|
}
|
|
@@ -34,6 +34,8 @@ export declare class ItemService {
|
|
|
34
34
|
getManyByGuidEnclosureUrl(channel: Channel, guidEnclosureUrls: string[], options?: FindManyOptions<Item>): Promise<Item[]>;
|
|
35
35
|
getManyByChannel(channel: Channel, options?: FindManyOptions<Item>): Promise<Item[]>;
|
|
36
36
|
getManyForQueueByPubDate(item_id_text: string, order: 'forward' | 'backward'): Promise<Item[]>;
|
|
37
|
+
getManyForQueueBySeason(item_id_text: string, order: 'forward' | 'backward'): Promise<Item[]>;
|
|
38
|
+
getManyByChannelBySeason(channel: Channel, order: 'forward' | 'backward', options?: FindManyOptions<Item>): Promise<Item[]>;
|
|
37
39
|
getManyByChannelWithLiveItem(channel: Channel, options?: FindManyOptions<Item>): Promise<Item[]>;
|
|
38
40
|
getManyByChannels(channels: Channel[], itemType: 'normal' | 'live-item', liveItemType: 'pending' | 'live' | 'ended' | null, options?: FindManyOptions<Item>): Promise<Item[]>;
|
|
39
41
|
getManyByChannelsWithLiveItem(channels: Channel[], options?: FindManyOptions<Item>): Promise<Item[]>;
|
|
@@ -47,7 +49,7 @@ export type ItemGetManyRelations = 'item_about' | 'item_about.item_itunes_episod
|
|
|
47
49
|
export declare const itemGetManyRelations: ItemGetManyRelations[];
|
|
48
50
|
export type SubItemGetManyRelations = 'item' | 'item.item_about' | 'item.item_chat' | 'item.item_description' | 'item.item_enclosures' | 'item.item_enclosures.item_enclosure_integrity' | 'item.item_enclosures.item_enclosure_sources' | 'item.item_images' | 'item.item_persons' | 'item.item_season' | 'item.item_season.channel_season' | 'item.live_item';
|
|
49
51
|
export declare const subItemGetManyRelations: SubItemGetManyRelations[];
|
|
50
|
-
export type ItemGetManyRelationsWithChannel = ItemGetManyRelations | 'channel' | 'channel.channel_images';
|
|
52
|
+
export type ItemGetManyRelationsWithChannel = ItemGetManyRelations | 'channel' | 'channel.channel_images' | 'channel.channel_about';
|
|
51
53
|
export declare const itemGetManyRelationsWithChannel: ItemGetManyRelationsWithChannel[];
|
|
52
54
|
export type SubItemGetManyRelationsWithChannel = SubItemGetManyRelations | 'item.channel' | 'item.channel.channel_images';
|
|
53
55
|
export declare const subItemGetManyRelationsWithChannel: SubItemGetManyRelationsWithChannel[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/services/item/item.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../src/services/item/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAC7C,UAAU,EACX,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAoB/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAG7E,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;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Aa,GACb,cAAc,GACd,aAAa,GACb,4BAA4B,GAC5B,WAAW,GACX,4BAA4B,CAAC;AAEjC,eAAO,MAAM,oBAAoB,EAAE,oBAAoB,EActD,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,MAAM,GACN,iBAAiB,GACjB,gBAAgB,GAChB,uBAAuB,GACvB,sBAAsB,GACtB,+CAA+C,GAC/C,6CAA6C,GAC7C,kBAAkB,GAClB,mBAAmB,GACnB,kBAAkB,GAClB,iCAAiC,GACjC,gBAAgB,CAAC;AAErB,eAAO,MAAM,uBAAuB,EAAE,uBAAuB,EAa5D,CAAC;AAEF,MAAM,MAAM,+BAA+B,GACvC,oBAAoB,GACpB,SAAS,GACT,wBAAwB,GACxB,uBAAuB,CAAA;AAE3B,eAAO,MAAM,+BAA+B,EAAE,+BAA+B,EAK5E,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAC1C,uBAAuB,GACvB,cAAc,GACd,6BAA6B,CAAC;AAElC,eAAO,MAAM,kCAAkC,EAAE,kCAAkC,EAIlF,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAAoB,CAAC,IAAI,CAmB1D,CAAC"}
|
|
@@ -326,6 +326,230 @@ class ItemService {
|
|
|
326
326
|
});
|
|
327
327
|
});
|
|
328
328
|
}
|
|
329
|
+
getManyForQueueBySeason(item_id_text, order) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
var _a, _b, _c, _d, _e, _f;
|
|
332
|
+
const item = yield this.repositoryRead.findOne({
|
|
333
|
+
where: { id_text: item_id_text },
|
|
334
|
+
relations: {
|
|
335
|
+
channel: true,
|
|
336
|
+
item_season: { channel_season: true },
|
|
337
|
+
item_season_episode: true
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
if (!item || !item.channel) {
|
|
341
|
+
return [];
|
|
342
|
+
}
|
|
343
|
+
const currentSeasonNumber = (_c = (_b = (_a = item.item_season) === null || _a === void 0 ? void 0 : _a.channel_season) === null || _b === void 0 ? void 0 : _b.number) !== null && _c !== void 0 ? _c : -1;
|
|
344
|
+
const currentEpisodeNumber = (_e = (_d = item.item_season_episode) === null || _d === void 0 ? void 0 : _d.number) !== null && _e !== void 0 ? _e : null;
|
|
345
|
+
const currentPubDate = (_f = item.pub_date) !== null && _f !== void 0 ? _f : null;
|
|
346
|
+
const LIMIT = 20;
|
|
347
|
+
// Helper function to create base query builder with all relations
|
|
348
|
+
const createBaseQueryBuilder = () => {
|
|
349
|
+
return this.repositoryRead.createQueryBuilder('item')
|
|
350
|
+
.leftJoinAndSelect('item.item_about', 'item_about')
|
|
351
|
+
.leftJoinAndSelect('item_about.item_itunes_episode_type', 'item_itunes_episode_type')
|
|
352
|
+
.leftJoinAndSelect('item.item_enclosures', 'item_enclosures')
|
|
353
|
+
.leftJoinAndSelect('item_enclosures.item_enclosure_sources', 'item_enclosure_sources')
|
|
354
|
+
.leftJoinAndSelect('item.item_images', 'item_images')
|
|
355
|
+
.leftJoinAndSelect('item.item_season', 'item_season')
|
|
356
|
+
.leftJoinAndSelect('item_season.channel_season', 'cs')
|
|
357
|
+
.leftJoinAndSelect('item.item_season_episode', 'item_season_episode')
|
|
358
|
+
.leftJoinAndSelect('item.channel', 'channel')
|
|
359
|
+
.leftJoinAndSelect('channel.channel_images', 'channel_images')
|
|
360
|
+
.leftJoinAndSelect('item.live_item', 'live_item')
|
|
361
|
+
.leftJoinAndSelect('item.item_flag_status', 'item_flag_status')
|
|
362
|
+
.where('item.channel_id = :channel_id', { channel_id: item.channel.id })
|
|
363
|
+
.andWhere('live_item.id IS NULL')
|
|
364
|
+
.andWhere('item_flag_status.id = :status', { status: itemFlagStatus_2.ItemFlagStatusStatusEnum.Active });
|
|
365
|
+
};
|
|
366
|
+
let finalResults = [];
|
|
367
|
+
if (currentSeasonNumber !== -1) {
|
|
368
|
+
// Current item has an actual season number
|
|
369
|
+
// Query for items with actual season numbers
|
|
370
|
+
const seasonedQuery = createBaseQueryBuilder()
|
|
371
|
+
.andWhere('cs.number IS NOT NULL');
|
|
372
|
+
if (order === 'forward') {
|
|
373
|
+
seasonedQuery
|
|
374
|
+
.andWhere(new typeorm_1.Brackets(qb => {
|
|
375
|
+
qb.where('cs.number > :seasonNum', { seasonNum: currentSeasonNumber })
|
|
376
|
+
.orWhere(new typeorm_1.Brackets(qb2 => {
|
|
377
|
+
qb2.where('cs.number = :seasonNum', { seasonNum: currentSeasonNumber })
|
|
378
|
+
.andWhere('item_season_episode.number > :episodeNum', { episodeNum: currentEpisodeNumber });
|
|
379
|
+
}));
|
|
380
|
+
}))
|
|
381
|
+
.orderBy('cs.number', 'ASC')
|
|
382
|
+
.addOrderBy('item_season_episode.number', 'ASC');
|
|
383
|
+
}
|
|
384
|
+
else { // backward
|
|
385
|
+
seasonedQuery
|
|
386
|
+
.andWhere(new typeorm_1.Brackets(qb => {
|
|
387
|
+
qb.where('cs.number < :seasonNum', { seasonNum: currentSeasonNumber })
|
|
388
|
+
.orWhere(new typeorm_1.Brackets(qb2 => {
|
|
389
|
+
qb2.where('cs.number = :seasonNum', { seasonNum: currentSeasonNumber })
|
|
390
|
+
.andWhere('item_season_episode.number < :episodeNum', { episodeNum: currentEpisodeNumber });
|
|
391
|
+
}));
|
|
392
|
+
}))
|
|
393
|
+
.orderBy('cs.number', 'DESC')
|
|
394
|
+
.addOrderBy('item_season_episode.number', 'DESC');
|
|
395
|
+
}
|
|
396
|
+
seasonedQuery.limit(LIMIT);
|
|
397
|
+
const seasonedResults = (yield seasonedQuery.getRawAndEntities()).entities;
|
|
398
|
+
finalResults = seasonedResults;
|
|
399
|
+
// If we have fewer than 20 items and direction is backward, fill with -1 season items
|
|
400
|
+
if (order === 'backward' && finalResults.length < LIMIT) {
|
|
401
|
+
const remaining = LIMIT - finalResults.length;
|
|
402
|
+
const unseasonedQuery = createBaseQueryBuilder()
|
|
403
|
+
.andWhere('cs.number IS NULL')
|
|
404
|
+
.andWhere('item.pub_date IS NOT NULL')
|
|
405
|
+
.orderBy('item.pub_date', 'ASC')
|
|
406
|
+
.limit(remaining);
|
|
407
|
+
const unseasonedResults = (yield unseasonedQuery.getRawAndEntities()).entities;
|
|
408
|
+
finalResults = [...finalResults, ...unseasonedResults];
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
// Current item does NOT have an actual season number (it's -1)
|
|
413
|
+
if (order === 'forward') {
|
|
414
|
+
// Query -1 items first
|
|
415
|
+
const unseasonedQuery = createBaseQueryBuilder()
|
|
416
|
+
.andWhere('cs.number IS NULL')
|
|
417
|
+
.andWhere('item.pub_date IS NOT NULL');
|
|
418
|
+
if (currentPubDate) {
|
|
419
|
+
unseasonedQuery.andWhere('item.pub_date < :currentPubDate', { currentPubDate });
|
|
420
|
+
}
|
|
421
|
+
unseasonedQuery
|
|
422
|
+
.orderBy('item.pub_date', 'DESC')
|
|
423
|
+
.limit(LIMIT);
|
|
424
|
+
const unseasonedResults = (yield unseasonedQuery.getRawAndEntities()).entities;
|
|
425
|
+
finalResults = unseasonedResults;
|
|
426
|
+
// If we have fewer than 20 items, fill with actual season items
|
|
427
|
+
if (finalResults.length < LIMIT) {
|
|
428
|
+
const remaining = LIMIT - finalResults.length;
|
|
429
|
+
const seasonedQuery = createBaseQueryBuilder()
|
|
430
|
+
.andWhere('cs.number IS NOT NULL')
|
|
431
|
+
.orderBy('cs.number', 'ASC')
|
|
432
|
+
.addOrderBy('item_season_episode.number', 'ASC')
|
|
433
|
+
.limit(remaining);
|
|
434
|
+
const seasonedResults = (yield seasonedQuery.getRawAndEntities()).entities;
|
|
435
|
+
finalResults = [...finalResults, ...seasonedResults];
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
else { // backward
|
|
439
|
+
// Only query -1 items
|
|
440
|
+
const unseasonedQuery = createBaseQueryBuilder()
|
|
441
|
+
.andWhere('cs.number IS NULL')
|
|
442
|
+
.andWhere('item.pub_date IS NOT NULL');
|
|
443
|
+
if (currentPubDate) {
|
|
444
|
+
unseasonedQuery.andWhere('item.pub_date > :currentPubDate', { currentPubDate });
|
|
445
|
+
}
|
|
446
|
+
unseasonedQuery
|
|
447
|
+
.orderBy('item.pub_date', 'ASC')
|
|
448
|
+
.limit(LIMIT);
|
|
449
|
+
const unseasonedResults = (yield unseasonedQuery.getRawAndEntities()).entities;
|
|
450
|
+
finalResults = unseasonedResults;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return finalResults.slice(0, LIMIT);
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
getManyByChannelBySeason(channel, order, options) {
|
|
457
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
458
|
+
var _a, _b;
|
|
459
|
+
if (!channel) {
|
|
460
|
+
return [];
|
|
461
|
+
}
|
|
462
|
+
const skip = (_a = options === null || options === void 0 ? void 0 : options.skip) !== null && _a !== void 0 ? _a : 0;
|
|
463
|
+
const take = (_b = options === null || options === void 0 ? void 0 : options.take) !== null && _b !== void 0 ? _b : podverse_helpers_1.PAGINATION.DEFAULT_LIMIT;
|
|
464
|
+
const createBaseQueryBuilder = () => {
|
|
465
|
+
return this.repositoryRead.createQueryBuilder('item')
|
|
466
|
+
.leftJoinAndSelect('item.item_about', 'item_about')
|
|
467
|
+
.leftJoinAndSelect('item_about.item_itunes_episode_type', 'item_itunes_episode_type')
|
|
468
|
+
.leftJoinAndSelect('item.item_enclosures', 'item_enclosures')
|
|
469
|
+
.leftJoinAndSelect('item_enclosures.item_enclosure_sources', 'item_enclosure_sources')
|
|
470
|
+
.leftJoinAndSelect('item.item_images', 'item_images')
|
|
471
|
+
.leftJoinAndSelect('item.item_season', 'item_season')
|
|
472
|
+
.leftJoinAndSelect('item_season.channel_season', 'cs')
|
|
473
|
+
.leftJoinAndSelect('item.item_season_episode', 'item_season_episode')
|
|
474
|
+
.leftJoinAndSelect('item.channel', 'channel')
|
|
475
|
+
.leftJoinAndSelect('channel.channel_images', 'channel_images')
|
|
476
|
+
.leftJoinAndSelect('item.live_item', 'live_item')
|
|
477
|
+
.leftJoinAndSelect('item.item_flag_status', 'item_flag_status')
|
|
478
|
+
.where('item.channel_id = :channel_id', { channel_id: channel.id })
|
|
479
|
+
.andWhere('live_item.id IS NULL')
|
|
480
|
+
.andWhere('item_flag_status.id = :status', { status: itemFlagStatus_2.ItemFlagStatusStatusEnum.Active });
|
|
481
|
+
};
|
|
482
|
+
let finalResults = [];
|
|
483
|
+
if (order === 'forward') {
|
|
484
|
+
// Forward = unseasoned items first (DESC pub_date), then seasoned items (ASC season/episode)
|
|
485
|
+
const unseasonedQuery = createBaseQueryBuilder()
|
|
486
|
+
.andWhere('cs.number IS NULL')
|
|
487
|
+
.andWhere('item.pub_date IS NOT NULL')
|
|
488
|
+
.orderBy('item.pub_date', 'DESC')
|
|
489
|
+
.skip(skip)
|
|
490
|
+
.take(take);
|
|
491
|
+
const unseasonedResults = (yield unseasonedQuery.getRawAndEntities()).entities;
|
|
492
|
+
finalResults = unseasonedResults;
|
|
493
|
+
if (finalResults.length < take) {
|
|
494
|
+
const remaining = take - finalResults.length;
|
|
495
|
+
const unseasonedCount = yield this.repositoryRead.createQueryBuilder('item')
|
|
496
|
+
.leftJoin('item.item_season', 'item_season')
|
|
497
|
+
.leftJoin('item_season.channel_season', 'cs')
|
|
498
|
+
.leftJoin('item.live_item', 'live_item')
|
|
499
|
+
.leftJoin('item.item_flag_status', 'item_flag_status')
|
|
500
|
+
.where('item.channel_id = :channel_id', { channel_id: channel.id })
|
|
501
|
+
.andWhere('live_item.id IS NULL')
|
|
502
|
+
.andWhere('item_flag_status.id = :status', { status: itemFlagStatus_2.ItemFlagStatusStatusEnum.Active })
|
|
503
|
+
.andWhere('cs.number IS NULL')
|
|
504
|
+
.andWhere('item.pub_date IS NOT NULL')
|
|
505
|
+
.getCount();
|
|
506
|
+
const seasonedSkip = Math.max(0, skip - unseasonedCount);
|
|
507
|
+
const seasonedQuery = createBaseQueryBuilder()
|
|
508
|
+
.andWhere('cs.number IS NOT NULL')
|
|
509
|
+
.orderBy('cs.number', 'ASC')
|
|
510
|
+
.addOrderBy('item_season_episode.number', 'ASC')
|
|
511
|
+
.skip(seasonedSkip)
|
|
512
|
+
.take(remaining);
|
|
513
|
+
const seasonedResults = (yield seasonedQuery.getRawAndEntities()).entities;
|
|
514
|
+
finalResults = [...finalResults, ...seasonedResults];
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
// Backward = seasoned items first (DESC season/episode), then unseasoned items (ASC pub_date)
|
|
519
|
+
const seasonedQuery = createBaseQueryBuilder()
|
|
520
|
+
.andWhere('cs.number IS NOT NULL')
|
|
521
|
+
.orderBy('cs.number', 'DESC')
|
|
522
|
+
.addOrderBy('item_season_episode.number', 'DESC')
|
|
523
|
+
.skip(skip)
|
|
524
|
+
.take(take);
|
|
525
|
+
const seasonedResults = (yield seasonedQuery.getRawAndEntities()).entities;
|
|
526
|
+
finalResults = seasonedResults;
|
|
527
|
+
if (finalResults.length < take) {
|
|
528
|
+
const remaining = take - finalResults.length;
|
|
529
|
+
const seasonedCount = yield this.repositoryRead.createQueryBuilder('item')
|
|
530
|
+
.leftJoin('item.item_season', 'item_season')
|
|
531
|
+
.leftJoin('item_season.channel_season', 'cs')
|
|
532
|
+
.leftJoin('item.live_item', 'live_item')
|
|
533
|
+
.leftJoin('item.item_flag_status', 'item_flag_status')
|
|
534
|
+
.where('item.channel_id = :channel_id', { channel_id: channel.id })
|
|
535
|
+
.andWhere('live_item.id IS NULL')
|
|
536
|
+
.andWhere('item_flag_status.id = :status', { status: itemFlagStatus_2.ItemFlagStatusStatusEnum.Active })
|
|
537
|
+
.andWhere('cs.number IS NOT NULL')
|
|
538
|
+
.getCount();
|
|
539
|
+
const unseasonedSkip = Math.max(0, skip - seasonedCount);
|
|
540
|
+
const unseasonedQuery = createBaseQueryBuilder()
|
|
541
|
+
.andWhere('cs.number IS NULL')
|
|
542
|
+
.andWhere('item.pub_date IS NOT NULL')
|
|
543
|
+
.orderBy('item.pub_date', 'ASC')
|
|
544
|
+
.skip(unseasonedSkip)
|
|
545
|
+
.take(remaining);
|
|
546
|
+
const unseasonedResults = (yield unseasonedQuery.getRawAndEntities()).entities;
|
|
547
|
+
finalResults = [...finalResults, ...unseasonedResults];
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return finalResults;
|
|
551
|
+
});
|
|
552
|
+
}
|
|
329
553
|
getManyByChannelWithLiveItem(channel, options) {
|
|
330
554
|
return __awaiter(this, void 0, void 0, function* () {
|
|
331
555
|
return this.repositoryRead.find(Object.assign({ where: {
|
|
@@ -458,7 +682,8 @@ exports.subItemGetManyRelations = [
|
|
|
458
682
|
exports.itemGetManyRelationsWithChannel = [
|
|
459
683
|
...exports.itemGetManyRelations,
|
|
460
684
|
'channel',
|
|
461
|
-
'channel.channel_images'
|
|
685
|
+
'channel.channel_images',
|
|
686
|
+
'channel.channel_about'
|
|
462
687
|
];
|
|
463
688
|
exports.subItemGetManyRelationsWithChannel = [
|
|
464
689
|
...exports.subItemGetManyRelations,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-orm",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.8-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"module-alias": "^2.2.3",
|
|
25
25
|
"nanoid": "^5.1.6",
|
|
26
26
|
"pg": "^8.16.3",
|
|
27
|
-
"podverse-helpers": "^5.1.
|
|
27
|
+
"podverse-helpers": "^5.1.8-alpha.0",
|
|
28
28
|
"typeorm": "^0.3.26",
|
|
29
29
|
"typeorm-naming-strategies": "^4.1.0"
|
|
30
30
|
},
|