podverse-orm 5.1.0-alpha.9 → 5.1.3-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.
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +5 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +0 -2
- package/dist/entities/account/account.d.ts +0 -2
- package/dist/entities/account/account.d.ts.map +1 -1
- package/dist/entities/account/account.js +2 -7
- package/dist/entities/channel/channel.d.ts +2 -1
- package/dist/entities/channel/channel.d.ts.map +1 -1
- package/dist/entities/channel/channel.js +8 -4
- package/dist/entities/channel/channelDescription.js +1 -1
- package/dist/entities/clip.d.ts +2 -0
- package/dist/entities/clip.d.ts.map +1 -1
- package/dist/entities/clip.js +10 -2
- package/dist/entities/item/item.d.ts +1 -0
- package/dist/entities/item/item.d.ts.map +1 -1
- package/dist/entities/item/item.js +6 -2
- package/dist/entities/item/itemChapter.d.ts +1 -0
- package/dist/entities/item/itemChapter.d.ts.map +1 -1
- package/dist/entities/item/itemChapter.js +6 -2
- package/dist/entities/item/itemDescription.js +1 -1
- package/dist/entities/item/itemEnclosure.js +1 -1
- package/dist/entities/item/itemSoundbite.js +2 -2
- package/dist/entities/playlist/playlist.d.ts +5 -0
- package/dist/entities/playlist/playlist.d.ts.map +1 -1
- package/dist/entities/playlist/playlist.js +19 -2
- package/dist/entities/playlist/playlistResource.d.ts +0 -3
- package/dist/entities/playlist/playlistResource.d.ts.map +1 -1
- package/dist/entities/playlist/playlistResource.js +0 -10
- package/dist/entities/queue/queue.d.ts +2 -0
- package/dist/entities/queue/queue.d.ts.map +1 -1
- package/dist/entities/queue/queue.js +10 -2
- package/dist/entities/queue/queueResource.d.ts +0 -3
- package/dist/entities/queue/queueResource.d.ts.map +1 -1
- package/dist/entities/queue/queueResource.js +0 -10
- package/dist/factories/loggerService.d.ts +3 -0
- package/dist/factories/loggerService.d.ts.map +1 -0
- package/dist/factories/loggerService.js +9 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/lib/feedFlagHelpers.d.ts +9 -0
- package/dist/lib/feedFlagHelpers.d.ts.map +1 -0
- package/dist/lib/feedFlagHelpers.js +12 -0
- package/dist/lib/nanoid.d.ts +2 -0
- package/dist/lib/nanoid.d.ts.map +1 -0
- package/dist/lib/nanoid.js +11 -0
- package/dist/lib/password.d.ts +2 -0
- package/dist/lib/password.d.ts.map +1 -0
- package/dist/lib/password.js +24 -0
- package/dist/services/account/account.d.ts +1 -1
- package/dist/services/account/account.d.ts.map +1 -1
- package/dist/services/account/account.js +5 -4
- package/dist/services/account/accountFollowingChannel.d.ts +4 -0
- package/dist/services/account/accountFollowingChannel.d.ts.map +1 -1
- package/dist/services/account/accountFollowingChannel.js +9 -0
- package/dist/services/account/accountFollowingPlaylist.d.ts +1 -0
- package/dist/services/account/accountFollowingPlaylist.d.ts.map +1 -1
- package/dist/services/account/accountFollowingPlaylist.js +9 -0
- package/dist/services/base/baseManyService.d.ts +4 -0
- package/dist/services/base/baseManyService.d.ts.map +1 -1
- package/dist/services/base/baseManyService.js +10 -3
- package/dist/services/base/baseOneService.d.ts.map +1 -1
- package/dist/services/base/baseOneService.js +3 -3
- package/dist/services/category.d.ts.map +1 -1
- package/dist/services/category.js +10 -4
- package/dist/services/channel/channel.d.ts +8 -3
- package/dist/services/channel/channel.d.ts.map +1 -1
- package/dist/services/channel/channel.js +40 -5
- package/dist/services/channel/channelPodroll.d.ts +7 -0
- package/dist/services/channel/channelPodroll.d.ts.map +1 -1
- package/dist/services/channel/channelPodroll.js +74 -0
- package/dist/services/clip.d.ts +3 -3
- package/dist/services/clip.d.ts.map +1 -1
- package/dist/services/clip.js +20 -3
- package/dist/services/feed/feed.js +1 -1
- package/dist/services/item/item.d.ts +13 -3
- package/dist/services/item/item.d.ts.map +1 -1
- package/dist/services/item/item.js +147 -38
- package/dist/services/item/itemChapter.d.ts +6 -0
- package/dist/services/item/itemChapter.d.ts.map +1 -1
- package/dist/services/item/itemChapter.js +44 -3
- package/dist/services/item/itemSoundbite.d.ts +5 -2
- package/dist/services/item/itemSoundbite.d.ts.map +1 -1
- package/dist/services/item/itemSoundbite.js +26 -2
- package/dist/services/item/itemTranscript.d.ts +2 -1
- package/dist/services/item/itemTranscript.d.ts.map +1 -1
- package/dist/services/item/itemTranscript.js +5 -0
- package/dist/services/playlist/playlist.d.ts +9 -5
- package/dist/services/playlist/playlist.d.ts.map +1 -1
- package/dist/services/playlist/playlist.js +55 -8
- package/dist/services/playlist/playlistResource.d.ts +3 -12
- package/dist/services/playlist/playlistResource.d.ts.map +1 -1
- package/dist/services/playlist/playlistResource.js +50 -61
- package/dist/services/queue/queue.d.ts +2 -3
- package/dist/services/queue/queue.d.ts.map +1 -1
- package/dist/services/queue/queue.js +36 -10
- package/dist/services/queue/queueResource.d.ts +19 -23
- package/dist/services/queue/queueResource.d.ts.map +1 -1
- package/dist/services/queue/queueResource.js +181 -102
- package/dist/services/stats/baseStatsAggregated.d.ts +23 -2
- package/dist/services/stats/baseStatsAggregated.d.ts.map +1 -1
- package/dist/services/stats/baseStatsAggregated.js +27 -5
- package/dist/services/stats/statsAggregatedAccount.d.ts.map +1 -1
- package/dist/services/stats/statsAggregatedAccount.js +1 -2
- package/dist/services/stats/statsAggregatedChannel.d.ts +6 -0
- package/dist/services/stats/statsAggregatedChannel.d.ts.map +1 -1
- package/dist/services/stats/statsAggregatedChannel.js +29 -2
- package/dist/services/stats/statsAggregatedClip.d.ts +3 -0
- package/dist/services/stats/statsAggregatedClip.d.ts.map +1 -1
- package/dist/services/stats/statsAggregatedClip.js +22 -2
- package/dist/services/stats/statsAggregatedItem.d.ts +3 -0
- package/dist/services/stats/statsAggregatedItem.d.ts.map +1 -1
- package/dist/services/stats/statsAggregatedItem.js +16 -2
- package/dist/services/stats/statsAggregatedPlaylist.d.ts +7 -0
- package/dist/services/stats/statsAggregatedPlaylist.d.ts.map +1 -1
- package/dist/services/stats/statsAggregatedPlaylist.js +70 -2
- package/dist/services/stats/statsTrackAccountGuid.d.ts.map +1 -1
- package/package.json +16 -13
- package/dist/entities/account/accountAdminRoles.d.ts +0 -8
- package/dist/entities/account/accountAdminRoles.d.ts.map +0 -1
- package/dist/entities/account/accountAdminRoles.js +0 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queueResource.d.ts","sourceRoot":"","sources":["../../../src/services/queue/queueResource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queueResource.d.ts","sourceRoot":"","sources":["../../../src/services/queue/queueResource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAW,aAAa,EAAE,eAAe,EAA8D,MAAM,SAAS,CAAC;AAC9H,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAQrE,eAAO,MAAM,qBAAqB,UAIjC,CAAC;AAEF,qBAAa,oBAAqB,SAAQ,eAAe,CAAC,aAAa,EAAE,OAAO,CAAC;IAC/E,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,oBAAoB,CAAuB;IAEnD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAiC;IAE1D,OAAO,CAAC,YAAY;gBAOR,0BAA0B,CAAC,EAAE,aAAa;IAQhD,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAwB3D,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IA4BhF,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAe5E,gCAAgC,CACpC,aAAa,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Aa,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAM3G,6BAA6B,CAAC,aAAa,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAiBpJ,2BAA2B,CAAC,aAAa,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAqB5G,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAwBzG,2BAA2B,CAAC,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQpG"}
|
|
@@ -9,42 +9,111 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.QueueResourceService = void 0;
|
|
12
|
+
exports.QueueResourceService = exports.listResourceRelations = void 0;
|
|
13
13
|
// TODO: get rid of "any" in the file
|
|
14
14
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
15
|
+
const async_mutex_1 = require("async-mutex");
|
|
16
|
+
const podverse_helpers_1 = require("podverse-helpers");
|
|
15
17
|
const typeorm_1 = require("typeorm");
|
|
16
18
|
const queueResource_1 = require("@orm/entities/queue/queueResource");
|
|
17
19
|
const baseManyService_1 = require("@orm/services/base/baseManyService");
|
|
18
20
|
const queue_1 = require("@orm/services/queue/queue");
|
|
19
21
|
const clip_1 = require("../clip");
|
|
20
22
|
const item_1 = require("../item/item");
|
|
21
|
-
const podverse_helpers_1 = require("podverse-helpers");
|
|
22
|
-
const itemChapter_1 = require("../item/itemChapter");
|
|
23
23
|
const itemSoundbite_1 = require("../item/itemSoundbite");
|
|
24
24
|
const QUEUE_LIST_POSITION_INCREMENT = 0.00000001;
|
|
25
|
+
exports.listResourceRelations = [
|
|
26
|
+
'clip', 'clip.item', 'clip.item.item_about', 'clip.item.item_enclosures', 'clip.item.item_enclosures.item_enclosure_sources', 'clip.item.item_images', 'clip.item.channel', 'clip.item.channel.channel_images',
|
|
27
|
+
'item', 'item.item_about', 'item.item_enclosures', 'item.item_enclosures.item_enclosure_sources', 'item.item_images', 'item.channel', 'item.channel.channel_images',
|
|
28
|
+
'item_soundbite', 'item_soundbite.item', 'item_soundbite.item.item_about', 'item_soundbite.item.item_enclosures', 'item_soundbite.item.item_enclosures.item_enclosure_sources', 'item_soundbite.item.item_images', 'item_soundbite.item.channel', 'item_soundbite.item.channel.channel_images'
|
|
29
|
+
];
|
|
25
30
|
class QueueResourceService extends baseManyService_1.BaseManyService {
|
|
31
|
+
getQueueLock(queue_id_text) {
|
|
32
|
+
if (!QueueResourceService.queueLocks.has(queue_id_text)) {
|
|
33
|
+
QueueResourceService.queueLocks.set(queue_id_text, new async_mutex_1.Mutex());
|
|
34
|
+
}
|
|
35
|
+
return QueueResourceService.queueLocks.get(queue_id_text);
|
|
36
|
+
}
|
|
26
37
|
constructor(transactionalEntityManager) {
|
|
27
38
|
super(queueResource_1.QueueResource, 'queue', transactionalEntityManager);
|
|
28
39
|
this.queueService = new queue_1.QueueService(transactionalEntityManager);
|
|
29
40
|
this.clipService = new clip_1.ClipService(transactionalEntityManager);
|
|
30
41
|
this.itemService = new item_1.ItemService();
|
|
31
|
-
this.itemChapterService = new itemChapter_1.ItemChapterService();
|
|
32
42
|
this.itemSoundbiteService = new itemSoundbite_1.ItemSoundbiteService();
|
|
33
43
|
}
|
|
34
|
-
|
|
44
|
+
getAllByAccountAbridged(account_id) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const queues = yield this.queueService.getAllPrivate(account_id);
|
|
47
|
+
if (!queues.length) {
|
|
48
|
+
throw new Error("No queues found for account.");
|
|
49
|
+
}
|
|
50
|
+
const queueIds = queues.map(q => q.id);
|
|
51
|
+
return this.repositoryRead
|
|
52
|
+
.createQueryBuilder("qr")
|
|
53
|
+
.select([
|
|
54
|
+
"qr.id AS i",
|
|
55
|
+
"qr.playback_position AS p",
|
|
56
|
+
"qr.media_file_duration AS d",
|
|
57
|
+
"qr.completed AS z",
|
|
58
|
+
"qr.clip_id AS c",
|
|
59
|
+
"qr.item_id AS t",
|
|
60
|
+
"qr.item_soundbite_id AS s",
|
|
61
|
+
"qr.add_by_rss_hash_id AS a"
|
|
62
|
+
])
|
|
63
|
+
.where("qr.queue_id IN (:...queueIds)", { queueIds })
|
|
64
|
+
.orderBy("qr.list_position", "ASC")
|
|
65
|
+
.getRawMany();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
getNowPlayingByQueueIdText(queue_id_text) {
|
|
35
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
70
|
const queue = yield this.queueService.getByIdText(queue_id_text);
|
|
37
71
|
if (!queue) {
|
|
38
72
|
throw new Error("Queue not found.");
|
|
39
73
|
}
|
|
40
74
|
const options = {
|
|
41
|
-
where: { queue: { id: queue.id } },
|
|
75
|
+
where: { queue: { id: queue.id }, list_position: (0, typeorm_1.MoreThanOrEqual)(0) },
|
|
42
76
|
order: { list_position: 'ASC' },
|
|
43
|
-
relations:
|
|
77
|
+
relations: exports.listResourceRelations
|
|
78
|
+
};
|
|
79
|
+
const rows = yield this.repositoryRead.find(options);
|
|
80
|
+
if (!rows || rows.length === 0) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const firstRow = rows[0];
|
|
84
|
+
if (parseFloat(firstRow.list_position) === 0) {
|
|
85
|
+
return firstRow;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
firstRow.list_position = '0';
|
|
89
|
+
yield this.repositoryReadWrite.save(firstRow);
|
|
90
|
+
return firstRow;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
getAllUpcomingByQueueIdText(queue_id_text) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const queue = yield this.queueService.getByIdText(queue_id_text);
|
|
97
|
+
if (!queue) {
|
|
98
|
+
throw new Error("Queue not found.");
|
|
99
|
+
}
|
|
100
|
+
const options = {
|
|
101
|
+
where: { queue: { id: queue.id }, list_position: (0, typeorm_1.MoreThan)(0) },
|
|
102
|
+
order: { list_position: 'ASC' },
|
|
103
|
+
relations: exports.listResourceRelations
|
|
44
104
|
};
|
|
45
105
|
return this.repositoryRead.find(options);
|
|
46
106
|
});
|
|
47
107
|
}
|
|
108
|
+
getHistoryResourcesByQueueIdText(queue_id_text, options) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const queue = yield this.queueService.getByIdText(queue_id_text);
|
|
111
|
+
if (!queue) {
|
|
112
|
+
throw new Error("Queue not found.");
|
|
113
|
+
}
|
|
114
|
+
return this.repositoryRead.findAndCount(Object.assign({ where: { queue: { id: queue.id }, list_position: (0, typeorm_1.LessThan)(0) }, order: { list_position: 'DESC' }, relations: exports.listResourceRelations }, options));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
48
117
|
getItemsByQueueIdTextAndPosition(queue_id_text, position) {
|
|
49
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
119
|
const queue = yield this.queueService.getByIdText(queue_id_text);
|
|
@@ -98,11 +167,12 @@ class QueueResourceService extends baseManyService_1.BaseManyService {
|
|
|
98
167
|
}
|
|
99
168
|
const { firstQueued, lastQueued } = yield this.getFirstAndLastQueuedItemsByQueueIdText(queue_id_text);
|
|
100
169
|
const list_position = calculatePosition(firstQueued, lastQueued);
|
|
170
|
+
const resourceKeyId = `${resourceKey}_id`;
|
|
101
171
|
const finalDto = {
|
|
102
|
-
[
|
|
172
|
+
[resourceKeyId]: resource.id,
|
|
103
173
|
list_position
|
|
104
174
|
};
|
|
105
|
-
return this._update(queue, [
|
|
175
|
+
return this._update(queue, [resourceKeyId], finalDto);
|
|
106
176
|
});
|
|
107
177
|
}
|
|
108
178
|
addResourceToQueueHelper(queue_id_text, resource_id_text, resourceService, resourceKey, calculatePosition) {
|
|
@@ -139,40 +209,99 @@ class QueueResourceService extends baseManyService_1.BaseManyService {
|
|
|
139
209
|
});
|
|
140
210
|
});
|
|
141
211
|
}
|
|
142
|
-
addResourceToNowPlaying(
|
|
143
|
-
return __awaiter(this,
|
|
144
|
-
const
|
|
145
|
-
|
|
212
|
+
addResourceToNowPlaying(queue_id_text_1, resource_id_text_1, resourceService_1, resourceKey_1) {
|
|
213
|
+
return __awaiter(this, arguments, void 0, function* (queue_id_text, resource_id_text, resourceService, resourceKey, params = {}) {
|
|
214
|
+
const lock = this.getQueueLock(queue_id_text);
|
|
215
|
+
return lock.runExclusive(() => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
return yield this.repositoryReadWrite.manager.transaction((manager) => __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
return this._addResourceToNowPlayingTransactional(manager, queue_id_text, resource_id_text, resourceService, resourceKey, params);
|
|
218
|
+
}));
|
|
219
|
+
}));
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
_addResourceToNowPlayingTransactional(manager_1, queue_id_text_1, resource_id_text_1, resourceService_1, resourceKey_1) {
|
|
223
|
+
return __awaiter(this, arguments, void 0, function* (manager, queue_id_text, resource_id_text, resourceService, resourceKey, params = {}) {
|
|
224
|
+
const queue = yield manager.findOne('Queue', { where: { id_text: queue_id_text } });
|
|
225
|
+
if (!queue)
|
|
146
226
|
throw new Error("Queue not found.");
|
|
147
|
-
}
|
|
148
227
|
const resource = yield resourceService.getByIdText(resource_id_text);
|
|
149
|
-
if (!resource)
|
|
228
|
+
if (!resource)
|
|
150
229
|
throw new Error(`${resourceKey} not found.`);
|
|
230
|
+
const epsilon = 1e-21;
|
|
231
|
+
const existingNowPlaying = yield manager.findOne(queueResource_1.QueueResource, {
|
|
232
|
+
where: { queue: { id: queue.id }, list_position: (0, typeorm_1.Between)(-epsilon, epsilon) }
|
|
233
|
+
});
|
|
234
|
+
if (existingNowPlaying &&
|
|
235
|
+
existingNowPlaying[`${resourceKey}_id`] === resource.id &&
|
|
236
|
+
existingNowPlaying.list_position === params.playback_position) {
|
|
237
|
+
return existingNowPlaying;
|
|
151
238
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
239
|
+
if (existingNowPlaying && resource.id !== existingNowPlaying.id) {
|
|
240
|
+
yield this.moveQueueResourceToHistoryByIdTransactional(manager, queue_id_text, existingNowPlaying.id);
|
|
241
|
+
}
|
|
242
|
+
let queueResource = yield manager.findOne(queueResource_1.QueueResource, {
|
|
243
|
+
where: { queue: { id: queue.id }, [`${resourceKey}_id`]: resource.id }
|
|
244
|
+
});
|
|
245
|
+
if (!queueResource) {
|
|
246
|
+
queueResource = manager.create(queueResource_1.QueueResource, Object.assign({ queue, [`${resourceKey}`]: resource, list_position: '0' }, params));
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
Object.assign(queueResource, Object.assign({ [`${resourceKey}`]: resource, list_position: '0' }, params));
|
|
250
|
+
}
|
|
251
|
+
return yield manager.save(queueResource);
|
|
157
252
|
});
|
|
158
253
|
}
|
|
159
|
-
|
|
160
|
-
return __awaiter(this,
|
|
161
|
-
const queue = yield
|
|
162
|
-
if (!queue)
|
|
254
|
+
moveQueueResourceToHistoryByIdTransactional(manager_1, queue_id_text_1, queue_resource_id_1) {
|
|
255
|
+
return __awaiter(this, arguments, void 0, function* (manager, queue_id_text, queue_resource_id, params = {}) {
|
|
256
|
+
const queue = yield manager.findOne('Queue', { where: { id_text: queue_id_text } });
|
|
257
|
+
if (!queue)
|
|
163
258
|
throw new Error("Queue not found.");
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const mostRecentHistoryItem = yield
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
259
|
+
const queueResource = yield manager.findOne(queueResource_1.QueueResource, {
|
|
260
|
+
where: { queue: { id: queue.id }, id: queue_resource_id }
|
|
261
|
+
});
|
|
262
|
+
if (!queueResource)
|
|
263
|
+
throw new Error("QueueResource not found.");
|
|
264
|
+
const mostRecentHistoryItem = yield manager.findOne(queueResource_1.QueueResource, {
|
|
265
|
+
where: { queue: { id: queue.id }, list_position: (0, typeorm_1.LessThan)(0) },
|
|
266
|
+
order: { list_position: 'DESC' }
|
|
267
|
+
});
|
|
268
|
+
const newPosition = mostRecentHistoryItem
|
|
269
|
+
? parseFloat(mostRecentHistoryItem.list_position) + QUEUE_LIST_POSITION_INCREMENT
|
|
270
|
+
: -1;
|
|
271
|
+
Object.assign(queueResource, Object.assign(Object.assign({}, params), { list_position: newPosition.toString() }));
|
|
272
|
+
return yield manager.save(queueResource);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
addResourceToHistory(queue_id_text, resource_id_text, resourceService, resourceKey, params) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
+
const lock = this.getQueueLock(queue_id_text);
|
|
278
|
+
return lock.runExclusive(() => __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
return yield this.repositoryReadWrite.manager.transaction((manager) => __awaiter(this, void 0, void 0, function* () {
|
|
280
|
+
const queue = yield manager.findOne('Queue', { where: { id_text: queue_id_text } });
|
|
281
|
+
if (!queue)
|
|
282
|
+
throw new Error("Queue not found.");
|
|
283
|
+
const resource = yield resourceService.getByIdText(resource_id_text);
|
|
284
|
+
if (!resource)
|
|
285
|
+
throw new Error(`${resourceKey} not found.`);
|
|
286
|
+
const mostRecentHistoryItem = yield manager.findOne(queueResource_1.QueueResource, {
|
|
287
|
+
where: { queue: { id: queue.id }, list_position: (0, typeorm_1.LessThan)(0) },
|
|
288
|
+
order: { list_position: 'DESC' }
|
|
289
|
+
});
|
|
290
|
+
const newPosition = mostRecentHistoryItem
|
|
291
|
+
? parseFloat(mostRecentHistoryItem.list_position) + QUEUE_LIST_POSITION_INCREMENT
|
|
292
|
+
: -1;
|
|
293
|
+
let queueResource = yield manager.findOne(queueResource_1.QueueResource, {
|
|
294
|
+
where: { queue: { id: queue.id }, [`${resourceKey}_id`]: resource.id }
|
|
295
|
+
});
|
|
296
|
+
if (!queueResource) {
|
|
297
|
+
queueResource = manager.create(queueResource_1.QueueResource, Object.assign({ queue, [`${resourceKey}`]: resource, list_position: newPosition.toString() }, params));
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
Object.assign(queueResource, Object.assign({ [`${resourceKey}`]: resource, list_position: newPosition.toString() }, params));
|
|
301
|
+
}
|
|
302
|
+
return yield manager.save(queueResource);
|
|
303
|
+
}));
|
|
304
|
+
}));
|
|
176
305
|
});
|
|
177
306
|
}
|
|
178
307
|
removeResourceFromQueue(queue_id_text, resource_id_text, resourceService, resourceKey) {
|
|
@@ -203,14 +332,14 @@ class QueueResourceService extends baseManyService_1.BaseManyService {
|
|
|
203
332
|
return this.addResourceToQueueBetween(queue_id_text, clip_id_text, this.clipService, 'clip', position1, position2);
|
|
204
333
|
});
|
|
205
334
|
}
|
|
206
|
-
addClipToNowPlaying(
|
|
207
|
-
return __awaiter(this,
|
|
208
|
-
return this.addResourceToNowPlaying(queue_id_text, clip_id_text, this.clipService, 'clip');
|
|
335
|
+
addClipToNowPlaying(queue_id_text_1, clip_id_text_1) {
|
|
336
|
+
return __awaiter(this, arguments, void 0, function* (queue_id_text, clip_id_text, params = {}) {
|
|
337
|
+
return this.addResourceToNowPlaying(queue_id_text, clip_id_text, this.clipService, 'clip', params);
|
|
209
338
|
});
|
|
210
339
|
}
|
|
211
|
-
addClipToHistory(queue_id_text, clip_id_text) {
|
|
340
|
+
addClipToHistory(queue_id_text, clip_id_text, params) {
|
|
212
341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
-
return this.addResourceToHistory(queue_id_text, clip_id_text, this.clipService, 'clip');
|
|
342
|
+
return this.addResourceToHistory(queue_id_text, clip_id_text, this.clipService, 'clip', params);
|
|
214
343
|
});
|
|
215
344
|
}
|
|
216
345
|
removeClipFromQueue(queue_id_text, clip_id_text) {
|
|
@@ -233,14 +362,14 @@ class QueueResourceService extends baseManyService_1.BaseManyService {
|
|
|
233
362
|
return this.addResourceToQueueBetween(queue_id_text, item_id_text, this.itemService, 'item', position1, position2);
|
|
234
363
|
});
|
|
235
364
|
}
|
|
236
|
-
addItemToNowPlaying(
|
|
237
|
-
return __awaiter(this,
|
|
238
|
-
return this.addResourceToNowPlaying(queue_id_text, item_id_text, this.itemService, 'item');
|
|
365
|
+
addItemToNowPlaying(queue_id_text_1, item_id_text_1) {
|
|
366
|
+
return __awaiter(this, arguments, void 0, function* (queue_id_text, item_id_text, params = {}) {
|
|
367
|
+
return this.addResourceToNowPlaying(queue_id_text, item_id_text, this.itemService, 'item', params);
|
|
239
368
|
});
|
|
240
369
|
}
|
|
241
|
-
addItemToHistory(queue_id_text, item_id_text) {
|
|
370
|
+
addItemToHistory(queue_id_text, item_id_text, params) {
|
|
242
371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
-
return this.addResourceToHistory(queue_id_text, item_id_text, this.itemService, 'item');
|
|
372
|
+
return this.addResourceToHistory(queue_id_text, item_id_text, this.itemService, 'item', params);
|
|
244
373
|
});
|
|
245
374
|
}
|
|
246
375
|
removeItemFromQueue(queue_id_text, item_id_text) {
|
|
@@ -248,36 +377,6 @@ class QueueResourceService extends baseManyService_1.BaseManyService {
|
|
|
248
377
|
return this.removeResourceFromQueue(queue_id_text, item_id_text, this.itemService, 'item');
|
|
249
378
|
});
|
|
250
379
|
}
|
|
251
|
-
addItemChapterToQueueNext(queue_id_text, item_chapter_id_text) {
|
|
252
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
-
return this.addResourceToQueueNext(queue_id_text, item_chapter_id_text, this.itemChapterService, 'item_chapter');
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
addItemChapterToQueueLast(queue_id_text, item_chapter_id_text) {
|
|
257
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
258
|
-
return this.addResourceToQueueLast(queue_id_text, item_chapter_id_text, this.itemChapterService, 'item_chapter');
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
addItemChapterToQueueBetween(queue_id_text, item_chapter_id_text, position1, position2) {
|
|
262
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
-
return this.addResourceToQueueBetween(queue_id_text, item_chapter_id_text, this.itemChapterService, 'item_chapter', position1, position2);
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
addItemChapterToNowPlaying(queue_id_text, item_chapter_id_text) {
|
|
267
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
268
|
-
return this.addResourceToNowPlaying(queue_id_text, item_chapter_id_text, this.itemChapterService, 'item_chapter');
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
addItemChapterToHistory(queue_id_text, item_chapter_id_text) {
|
|
272
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
273
|
-
return this.addResourceToHistory(queue_id_text, item_chapter_id_text, this.itemChapterService, 'item_chapter');
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
removeItemChapterFromQueue(queue_id_text, item_chapter_id_text) {
|
|
277
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
-
return this.removeResourceFromQueue(queue_id_text, item_chapter_id_text, this.itemChapterService, 'item_chapter');
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
380
|
addItemSoundbiteToQueueNext(queue_id_text, item_soundbite_id_text) {
|
|
282
381
|
return __awaiter(this, void 0, void 0, function* () {
|
|
283
382
|
return this.addResourceToQueueNext(queue_id_text, item_soundbite_id_text, this.itemSoundbiteService, 'item_soundbite');
|
|
@@ -293,14 +392,14 @@ class QueueResourceService extends baseManyService_1.BaseManyService {
|
|
|
293
392
|
return this.addResourceToQueueBetween(queue_id_text, item_soundbite_id_text, this.itemSoundbiteService, 'item_soundbite', position1, position2);
|
|
294
393
|
});
|
|
295
394
|
}
|
|
296
|
-
addItemSoundbiteToNowPlaying(
|
|
297
|
-
return __awaiter(this,
|
|
298
|
-
return this.addResourceToNowPlaying(queue_id_text, item_soundbite_id_text, this.itemSoundbiteService, 'item_soundbite');
|
|
395
|
+
addItemSoundbiteToNowPlaying(queue_id_text_1, item_soundbite_id_text_1) {
|
|
396
|
+
return __awaiter(this, arguments, void 0, function* (queue_id_text, item_soundbite_id_text, params = {}) {
|
|
397
|
+
return this.addResourceToNowPlaying(queue_id_text, item_soundbite_id_text, this.itemSoundbiteService, 'item_soundbite', params);
|
|
299
398
|
});
|
|
300
399
|
}
|
|
301
|
-
addItemSoundbiteToHistory(queue_id_text, item_soundbite_id_text) {
|
|
400
|
+
addItemSoundbiteToHistory(queue_id_text, item_soundbite_id_text, params) {
|
|
302
401
|
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
-
return this.addResourceToHistory(queue_id_text, item_soundbite_id_text, this.itemSoundbiteService, 'item_soundbite');
|
|
402
|
+
return this.addResourceToHistory(queue_id_text, item_soundbite_id_text, this.itemSoundbiteService, 'item_soundbite', params);
|
|
304
403
|
});
|
|
305
404
|
}
|
|
306
405
|
removeItemSoundbiteFromQueue(queue_id_text, item_soundbite_id_text) {
|
|
@@ -401,26 +500,6 @@ class QueueResourceService extends baseManyService_1.BaseManyService {
|
|
|
401
500
|
return this._delete(queue, { add_by_rss_hash_id });
|
|
402
501
|
});
|
|
403
502
|
}
|
|
404
|
-
getResourcesByParams(params) {
|
|
405
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
406
|
-
const whereClause = {};
|
|
407
|
-
if (params.clip_id) {
|
|
408
|
-
whereClause.clip = { id: params.clip_id };
|
|
409
|
-
}
|
|
410
|
-
if (params.item_id) {
|
|
411
|
-
whereClause.item = { id: params.item_id };
|
|
412
|
-
}
|
|
413
|
-
if (params.item_chapter_id) {
|
|
414
|
-
whereClause.item_chapter = { id: params.item_chapter_id };
|
|
415
|
-
}
|
|
416
|
-
if (params.item_soundbite_id) {
|
|
417
|
-
whereClause.item_soundbite = { id: params.item_soundbite_id };
|
|
418
|
-
}
|
|
419
|
-
return this.repositoryRead.find({
|
|
420
|
-
where: whereClause,
|
|
421
|
-
relations: ['clip', 'item', 'item_chapter', 'item_soundbite', 'queue']
|
|
422
|
-
});
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
503
|
}
|
|
426
504
|
exports.QueueResourceService = QueueResourceService;
|
|
505
|
+
QueueResourceService.queueLocks = new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Repository, ObjectLiteral } from 'typeorm';
|
|
1
|
+
import { Repository, ObjectLiteral, EntityTarget } from 'typeorm';
|
|
2
2
|
export type UpdateHistoricalOptions = {
|
|
3
3
|
daily: boolean;
|
|
4
4
|
weekly: boolean;
|
|
@@ -24,9 +24,30 @@ interface BaseAggregatedStats extends ObjectLiteral {
|
|
|
24
24
|
month_1_count?: number;
|
|
25
25
|
all_time_count?: number;
|
|
26
26
|
}
|
|
27
|
+
export declare const STATS_AGGREGATED_SELECT_ALL: {
|
|
28
|
+
id: boolean;
|
|
29
|
+
day_current_count: boolean;
|
|
30
|
+
day_1_count: boolean;
|
|
31
|
+
day_2_count: boolean;
|
|
32
|
+
day_3_count: boolean;
|
|
33
|
+
day_4_count: boolean;
|
|
34
|
+
day_5_count: boolean;
|
|
35
|
+
day_6_count: boolean;
|
|
36
|
+
day_7_count: boolean;
|
|
37
|
+
day_8_count: boolean;
|
|
38
|
+
week_current_count: boolean;
|
|
39
|
+
week_1_count: boolean;
|
|
40
|
+
week_2_count: boolean;
|
|
41
|
+
week_3_count: boolean;
|
|
42
|
+
week_4_count: boolean;
|
|
43
|
+
month_current_count: boolean;
|
|
44
|
+
month_1_count: boolean;
|
|
45
|
+
all_time_count: boolean;
|
|
46
|
+
};
|
|
27
47
|
export declare abstract class BaseStatsAggregatedService<T extends BaseAggregatedStats, ID> {
|
|
48
|
+
protected repositoryRead: Repository<T>;
|
|
28
49
|
protected repositoryReadWrite: Repository<T>;
|
|
29
|
-
constructor(
|
|
50
|
+
constructor(entity: EntityTarget<T>);
|
|
30
51
|
protected abstract getIdFieldName(): string;
|
|
31
52
|
_updateAggregatedStats(entity_id: ID, statsTrackEventService: any, updateAllTime?: boolean): Promise<void>;
|
|
32
53
|
_updateAggregatedStatsRolling(entity_id: ID, statsTrackEventService: any, updateHistoricalOptions: UpdateHistoricalOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseStatsAggregated.d.ts","sourceRoot":"","sources":["../../../src/services/stats/baseStatsAggregated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAoB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"baseStatsAggregated.d.ts","sourceRoot":"","sources":["../../../src/services/stats/baseStatsAggregated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAoB,YAAY,EAAE,MAAM,SAAS,CAAC;AAIpF,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAA;AAED,UAAU,mBAAoB,SAAQ,aAAa;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;CAmBvC,CAAC;AAEF,8BAAsB,0BAA0B,CAAC,CAAC,SAAS,mBAAmB,EAAE,EAAE;IAChF,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,SAAS,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;gBAEjC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAKnC,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,MAAM;IAGrC,sBAAsB,CAAC,SAAS,EAAE,EAAE,EAAE,sBAAsB,EAAE,GAAG,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBjH,6BAA6B,CAAC,SAAS,EAAE,EAAE,EAAE,sBAAsB,EAAE,GAAG,EAAE,uBAAuB,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkEjJ"}
|
|
@@ -9,11 +9,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.BaseStatsAggregatedService = void 0;
|
|
12
|
+
exports.BaseStatsAggregatedService = exports.STATS_AGGREGATED_SELECT_ALL = void 0;
|
|
13
13
|
const podverse_helpers_1 = require("podverse-helpers");
|
|
14
|
+
const db_1 = require("@orm/db");
|
|
15
|
+
exports.STATS_AGGREGATED_SELECT_ALL = {
|
|
16
|
+
id: true,
|
|
17
|
+
day_current_count: true,
|
|
18
|
+
day_1_count: true,
|
|
19
|
+
day_2_count: true,
|
|
20
|
+
day_3_count: true,
|
|
21
|
+
day_4_count: true,
|
|
22
|
+
day_5_count: true,
|
|
23
|
+
day_6_count: true,
|
|
24
|
+
day_7_count: true,
|
|
25
|
+
day_8_count: true,
|
|
26
|
+
week_current_count: true,
|
|
27
|
+
week_1_count: true,
|
|
28
|
+
week_2_count: true,
|
|
29
|
+
week_3_count: true,
|
|
30
|
+
week_4_count: true,
|
|
31
|
+
month_current_count: true,
|
|
32
|
+
month_1_count: true,
|
|
33
|
+
all_time_count: true
|
|
34
|
+
};
|
|
14
35
|
class BaseStatsAggregatedService {
|
|
15
|
-
constructor(
|
|
16
|
-
this.
|
|
36
|
+
constructor(entity) {
|
|
37
|
+
this.repositoryRead = db_1.AppDataSourceRead.getRepository(entity);
|
|
38
|
+
this.repositoryReadWrite = db_1.AppDataSourceReadWrite.getRepository(entity);
|
|
17
39
|
}
|
|
18
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
41
|
_updateAggregatedStats(entity_id_1, statsTrackEventService_1) {
|
|
@@ -23,7 +45,7 @@ class BaseStatsAggregatedService {
|
|
|
23
45
|
const eventCountWeek = yield statsTrackEventService._getCountWithinTimeFrame(entity_id, podverse_helpers_1.TIME_CONSTANTS.ONE_WEEK_IN_MINUTES);
|
|
24
46
|
const eventCountMonth = yield statsTrackEventService._getCountWithinTimeFrame(entity_id, podverse_helpers_1.TIME_CONSTANTS.ONE_MONTH_IN_MINUTES);
|
|
25
47
|
const idFieldName = this.getIdFieldName();
|
|
26
|
-
let aggregatedStats = yield this.
|
|
48
|
+
let aggregatedStats = yield this.repositoryRead.findOne({ where: { [idFieldName]: entity_id } });
|
|
27
49
|
if (!aggregatedStats) {
|
|
28
50
|
aggregatedStats = this.repositoryReadWrite.create({ [idFieldName]: entity_id });
|
|
29
51
|
}
|
|
@@ -42,7 +64,7 @@ class BaseStatsAggregatedService {
|
|
|
42
64
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
43
65
|
const eventCount = yield statsTrackEventService._getCountWithinTimeFrame(entity_id, podverse_helpers_1.TIME_CONSTANTS.ONE_DAY_IN_MINUTES);
|
|
44
66
|
const idFieldName = this.getIdFieldName();
|
|
45
|
-
let aggregatedStats = yield this.
|
|
67
|
+
let aggregatedStats = yield this.repositoryRead.findOne({ where: { [idFieldName]: entity_id } });
|
|
46
68
|
if (!aggregatedStats) {
|
|
47
69
|
aggregatedStats = this.repositoryReadWrite.create({ [idFieldName]: entity_id });
|
|
48
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statsAggregatedAccount.d.ts","sourceRoot":"","sources":["../../../src/services/stats/statsAggregatedAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"statsAggregatedAccount.d.ts","sourceRoot":"","sources":["../../../src/services/stats/statsAggregatedAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,qBAAa,6BAA8B,SAAQ,0BAA0B,CAAC,sBAAsB,EAAE,MAAM,CAAC;IAC3G,OAAO,CAAC,6BAA6B,CAAgC;;IAOrE,SAAS,CAAC,cAAc,IAAI,MAAM;IAI5B,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxF,4BAA4B,CAAC,UAAU,EAAE,MAAM,EAAE,uBAAuB,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxH"}
|
|
@@ -10,13 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.StatsAggregatedAccountService = void 0;
|
|
13
|
-
const db_1 = require("@orm/db");
|
|
14
13
|
const statsAggregatedAccount_1 = require("@orm/entities/stats/statsAggregatedAccount");
|
|
15
14
|
const statsTrackEventAccount_1 = require("./statsTrackEventAccount");
|
|
16
15
|
const baseStatsAggregated_1 = require("./baseStatsAggregated");
|
|
17
16
|
class StatsAggregatedAccountService extends baseStatsAggregated_1.BaseStatsAggregatedService {
|
|
18
17
|
constructor() {
|
|
19
|
-
super(
|
|
18
|
+
super(statsAggregatedAccount_1.StatsAggregatedAccount);
|
|
20
19
|
this.statsTrackEventAccountService = new statsTrackEventAccount_1.StatsTrackEventAccountService();
|
|
21
20
|
}
|
|
22
21
|
getIdFieldName() {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { FindManyOptions } from 'typeorm';
|
|
1
2
|
import { StatsAggregatedChannel } from '@orm/entities/stats/statsAggregatedChannel';
|
|
2
3
|
import { BaseStatsAggregatedService, UpdateHistoricalOptions } from './baseStatsAggregated';
|
|
3
4
|
export declare class StatsAggregatedChannelService extends BaseStatsAggregatedService<StatsAggregatedChannel, number> {
|
|
4
5
|
private statsTrackEventChannelService;
|
|
5
6
|
constructor();
|
|
6
7
|
protected getIdFieldName(): string;
|
|
8
|
+
private mergeWhere;
|
|
9
|
+
getMany(config: FindManyOptions<StatsAggregatedChannel>): Promise<StatsAggregatedChannel[]>;
|
|
10
|
+
getManyCount(config: FindManyOptions<StatsAggregatedChannel>): Promise<number>;
|
|
11
|
+
getManyByChannels(channel_ids: number[], config: FindManyOptions<StatsAggregatedChannel>): Promise<StatsAggregatedChannel[]>;
|
|
12
|
+
getManyByChannelsCount(channel_ids: number[], config: FindManyOptions<StatsAggregatedChannel>): Promise<number>;
|
|
7
13
|
updateAggregatedStats(channel_id: number, updateAllTime?: boolean): Promise<void>;
|
|
8
14
|
updateAggregatedStatsRolling(channel_id: number, updateHistoricalOptions: UpdateHistoricalOptions): Promise<void>;
|
|
9
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statsAggregatedChannel.d.ts","sourceRoot":"","sources":["../../../src/services/stats/statsAggregatedChannel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"statsAggregatedChannel.d.ts","sourceRoot":"","sources":["../../../src/services/stats/statsAggregatedChannel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAG5F,qBAAa,6BAA8B,SAAQ,0BAA0B,CAAC,sBAAsB,EAAE,MAAM,CAAC;IAC3G,OAAO,CAAC,6BAA6B,CAAgC;;IAOrE,SAAS,CAAC,cAAc,IAAI,MAAM;IAIlC,OAAO,CAAC,UAAU;IAIZ,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAQ3F,YAAY,CAAC,MAAM,EAAE,eAAe,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ9E,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,eAAe,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAQ5H,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,eAAe,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ/G,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxF,4BAA4B,CAAC,UAAU,EAAE,MAAM,EAAE,uBAAuB,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxH"}
|
|
@@ -10,18 +10,45 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.StatsAggregatedChannelService = void 0;
|
|
13
|
-
const db_1 = require("@orm/db");
|
|
14
13
|
const statsAggregatedChannel_1 = require("@orm/entities/stats/statsAggregatedChannel");
|
|
15
14
|
const statsTrackEventChannel_1 = require("./statsTrackEventChannel");
|
|
16
15
|
const baseStatsAggregated_1 = require("./baseStatsAggregated");
|
|
16
|
+
const feedFlagHelpers_1 = require("@orm/lib/feedFlagHelpers");
|
|
17
17
|
class StatsAggregatedChannelService extends baseStatsAggregated_1.BaseStatsAggregatedService {
|
|
18
18
|
constructor() {
|
|
19
|
-
super(
|
|
19
|
+
super(statsAggregatedChannel_1.StatsAggregatedChannel);
|
|
20
20
|
this.statsTrackEventChannelService = new statsTrackEventChannel_1.StatsTrackEventChannelService();
|
|
21
21
|
}
|
|
22
22
|
getIdFieldName() {
|
|
23
23
|
return 'channel_id';
|
|
24
24
|
}
|
|
25
|
+
mergeWhere(feedWhere, configWhere) {
|
|
26
|
+
return Object.assign(Object.assign({}, (feedWhere || {})), (configWhere || {}));
|
|
27
|
+
}
|
|
28
|
+
getMany(config) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const feedWhere = (0, feedFlagHelpers_1.getActiveFeedWhere)();
|
|
31
|
+
return this.repositoryRead.find(Object.assign(Object.assign({}, config), { where: this.mergeWhere(feedWhere, config.where) }));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
getManyCount(config) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const feedWhere = (0, feedFlagHelpers_1.getActiveFeedWhere)();
|
|
37
|
+
return this.repositoryRead.count(Object.assign(Object.assign({}, config), { where: this.mergeWhere(feedWhere, config.where) }));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
getManyByChannels(channel_ids, config) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const feedWhere = (0, feedFlagHelpers_1.getActiveFeedWhere)(channel_ids);
|
|
43
|
+
return this.repositoryRead.find(Object.assign(Object.assign({}, config), { where: this.mergeWhere(feedWhere, config.where) }));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getManyByChannelsCount(channel_ids, config) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const feedWhere = (0, feedFlagHelpers_1.getActiveFeedWhere)(channel_ids);
|
|
49
|
+
return this.repositoryRead.count(Object.assign(Object.assign({}, config), { where: this.mergeWhere(feedWhere, config.where) }));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
25
52
|
updateAggregatedStats(channel_id_1) {
|
|
26
53
|
return __awaiter(this, arguments, void 0, function* (channel_id, updateAllTime = false) {
|
|
27
54
|
yield this._updateAggregatedStats(channel_id, this.statsTrackEventChannelService, updateAllTime);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { StatsAggregatedClip } from '@orm/entities/stats/statsAggregatedClip';
|
|
2
2
|
import { BaseStatsAggregatedService, UpdateHistoricalOptions } from './baseStatsAggregated';
|
|
3
|
+
import { FindManyOptions } from 'typeorm';
|
|
3
4
|
export declare class StatsAggregatedClipService extends BaseStatsAggregatedService<StatsAggregatedClip, number> {
|
|
4
5
|
private statsTrackEventClipService;
|
|
5
6
|
constructor();
|
|
6
7
|
protected getIdFieldName(): string;
|
|
8
|
+
getMany(config: FindManyOptions<StatsAggregatedClip>): Promise<StatsAggregatedClip[]>;
|
|
9
|
+
getManyAndCountPublic(config: FindManyOptions<StatsAggregatedClip>): Promise<[StatsAggregatedClip[], number]>;
|
|
7
10
|
updateAggregatedStats(clip_id: number, updateAllTime?: boolean): Promise<void>;
|
|
8
11
|
updateAggregatedStatsRolling(clip_id: number, updateHistoricalOptions: UpdateHistoricalOptions): Promise<void>;
|
|
9
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statsAggregatedClip.d.ts","sourceRoot":"","sources":["../../../src/services/stats/statsAggregatedClip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"statsAggregatedClip.d.ts","sourceRoot":"","sources":["../../../src/services/stats/statsAggregatedClip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI1C,qBAAa,0BAA2B,SAAQ,0BAA0B,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrG,OAAO,CAAC,0BAA0B,CAA6B;;IAO/D,SAAS,CAAC,cAAc,IAAI,MAAM;IAI5B,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAarF,qBAAqB,CAAC,MAAM,EAAE,eAAe,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,CAAC,mBAAmB,EAAE,EAAE,MAAM,CAAC,CAAC;IAc7G,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrF,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;CAGrH"}
|