Skip to content

Commit

Permalink
🔊 log subscription cronjob time
Browse files Browse the repository at this point in the history
  • Loading branch information
moisout committed Sep 21, 2020
1 parent b844e60 commit 0d565a7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/user/subscriptions/subscriptions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ export class SubscriptionsService {

@Cron(CronExpression.EVERY_30_MINUTES)
async collectSubscriptionsJob(): Promise<void> {
console.time('subscription-job');
const users = await this.subscriptionModel.find().lean(true).exec();
const channelIds = users.reduce(
(val, { subscriptions }) => [...val, ...subscriptions.map(e => e.channelId)],
[]
);
const uniqueChannelIds = [...new Set(channelIds)];

console.log(uniqueChannelIds.length + ' unique channels');

const feedRequests = uniqueChannelIds.map(async id => {
const channelFeed = await this.getChannelFeed(id);
if (channelFeed) {
Expand Down Expand Up @@ -73,6 +76,7 @@ export class SubscriptionsService {
}
})
);
console.timeEnd('subscription-job');
}
}

Expand Down Expand Up @@ -116,7 +120,6 @@ export class SubscriptionsService {
const jsonData = x2js.xml2js(data) as any;
// console.log(jsonData);
if (jsonData.feed.entry) {
console.log(jsonData.feed.entry.length);
let videos: Array<VideoBasicInfoDto> = [];
// For channels that have no videos
if (jsonData.feed.entry.length) {
Expand Down

0 comments on commit 0d565a7

Please sign in to comment.