From d23a7d56c013cde1aec2be78dddf6cca3bfab75e Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 27 Mar 2024 13:54:54 +0800 Subject: [PATCH 1/2] Only check for summaries if the updated entity is a page item --- packages/api/src/pubsub.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/api/src/pubsub.ts b/packages/api/src/pubsub.ts index c64b45900..237a5801f 100644 --- a/packages/api/src/pubsub.ts +++ b/packages/api/src/pubsub.ts @@ -86,22 +86,24 @@ export const createPubSubClient = (): PubsubClient => { data, }) - if (await findFeatureByName(FeatureName.AISummaries, userId)) { - // await enqueueAISummarizeJob({ - // userId, - // libraryItemId, - // }) - } + if (type === EntityType.PAGE) { + if (await findFeatureByName(FeatureName.AISummaries, userId)) { + // await enqueueAISummarizeJob({ + // userId, + // libraryItemId, + // }) + } - const isYoutubeVideo = (data: any): data is { originalUrl: string } => { - return 'originalUrl' in data - } + const isYoutubeVideo = (data: any): data is { originalUrl: string } => { + return 'originalUrl' in data + } - if (isYoutubeVideo(data) && isYouTubeVideoURL(data['originalUrl'])) { - await enqueueProcessYouTubeVideo({ - userId, - libraryItemId, - }) + if (isYoutubeVideo(data) && isYouTubeVideoURL(data['originalUrl'])) { + await enqueueProcessYouTubeVideo({ + userId, + libraryItemId, + }) + } } }, entityUpdated: async >( From 38f959685f751662a70850fcee57c43511bf2b82 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 27 Mar 2024 15:41:15 +0800 Subject: [PATCH 2/2] Change warn to warning --- packages/api/src/jobs/process-youtube-video.ts | 18 +++++++++++------- packages/api/src/queue-processor.ts | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/api/src/jobs/process-youtube-video.ts b/packages/api/src/jobs/process-youtube-video.ts index 07f3f5c3c..2802e89a6 100644 --- a/packages/api/src/jobs/process-youtube-video.ts +++ b/packages/api/src/jobs/process-youtube-video.ts @@ -360,7 +360,7 @@ export const processYouTubeVideo = async ( const videoId = videoURL.searchParams.get('v') if (!videoId) { - logger.warn('no video id for supplied youtube url', { + logger.warning('no video id for supplied youtube url', { url: libraryItem.originalUrl, }) return @@ -370,7 +370,7 @@ export const processYouTubeVideo = async ( const youtube = new YouTubeClient() const video = await youtube.getVideo(videoId) if (!video) { - logger.warn('no video found for youtube url', { + logger.warning('no video found for youtube url', { url: libraryItem.originalUrl, }) return @@ -427,11 +427,15 @@ export const processYouTubeVideo = async ( jobData.userId ) if (!updated) { - logger.warn('could not updated library item') + logger.warning('could not updated library item') } } } catch (err) { - logger.warn('error getting youtube metadata: ', { err, jobData, videoURL }) + logger.warning('error getting youtube metadata: ', { + err, + jobData, + videoURL, + }) } } @@ -470,7 +474,7 @@ export const processYouTubeTranscript = async ( const youtube = new YouTubeClient() const video = await youtube.getVideo(jobData.videoId) if (!video) { - logger.warn('no video found for youtube url', { + logger.warning('no video found for youtube url', { url: libraryItem.originalUrl, }) return @@ -517,10 +521,10 @@ export const processYouTubeTranscript = async ( jobData.userId ) if (!updated) { - logger.warn('could not updated library item') + logger.warning('could not updated library item') } } } catch (err) { - logger.warn('error getting youtube transcript: ', { err, jobData }) + logger.warning('error getting youtube transcript: ', { err, jobData }) } } diff --git a/packages/api/src/queue-processor.ts b/packages/api/src/queue-processor.ts index 2e97a9686..cda9d9e7a 100644 --- a/packages/api/src/queue-processor.ts +++ b/packages/api/src/queue-processor.ts @@ -158,7 +158,7 @@ export const createWorker = (connection: ConnectionOptions) => case EXPORT_ALL_ITEMS_JOB_NAME: return exportAllItems(job.data) default: - logger.warn(`[queue-processor] unhandled job: ${job.name}`) + logger.warning(`[queue-processor] unhandled job: ${job.name}`) } }, {