@@ -123,6 +123,8 @@ async function sendJobNotifications(
123123 jobId : string
124124) : Promise < void > {
125125 try {
126+ console . log ( `📬 Checking notifications for job ${ jobId } , repo ${ repoId } , user ${ userId } ` ) ;
127+
126128 // Get repo settings
127129 const settingsResult = await db . query (
128130 `SELECT rs.*, r.full_name
@@ -132,16 +134,23 @@ async function sendJobNotifications(
132134 [ repoId ]
133135 ) ;
134136
135- if ( settingsResult . rows . length === 0 ) return ;
137+ if ( settingsResult . rows . length === 0 ) {
138+ console . log ( '⚠️ No repo_settings found for repo:' , repoId ) ;
139+ return ;
140+ }
136141
137142 const settings = settingsResult . rows [ 0 ] ;
143+ console . log ( `📬 Settings found: notify_email=${ settings . notify_email } , schedule=${ settings . schedule } ` ) ;
138144
139145 // Get user email
140146 const userResult = await db . query ( 'SELECT email FROM users WHERE id = $1' , [ userId ] ) ;
141147 const userEmail = userResult . rows [ 0 ] ?. email ;
148+ console . log ( `📬 User email: ${ userEmail || 'NOT FOUND' } ` ) ;
142149
143150 // Send email notification
144151 if ( settings . notify_email && userEmail ) {
152+ console . log ( `📧 Email notifications enabled, preparing to send to ${ userEmail } ...` ) ;
153+
145154 // Fetch the maintainer_brief output for this job
146155 const briefResult = await db . query (
147156 `SELECT content_markdown FROM analysis_outputs
@@ -150,6 +159,7 @@ async function sendJobNotifications(
150159 ) ;
151160
152161 const maintainerBrief = briefResult . rows [ 0 ] ?. content_markdown || '' ;
162+ console . log ( `📧 Maintainer brief content length: ${ maintainerBrief . length } chars` ) ;
153163
154164 // Build rich email with extracted content
155165 const briefData : WeeklyBriefData = {
@@ -167,10 +177,15 @@ async function sendJobNotifications(
167177 schedule : settings . schedule || 'weekly' ,
168178 } ;
169179
180+ console . log ( `📧 Email data prepared: TL;DR items=${ briefData . tldr . length } , Risky=${ briefData . riskyChanges . length } , Actions=${ briefData . suggestedActions . length } ` ) ;
181+
170182 const { subject, html } = buildWeeklyBriefEmail ( briefData ) ;
183+ console . log ( `📧 Email built, subject: "${ subject } ", HTML length: ${ html . length } chars` ) ;
171184
172185 await sendHtmlEmail ( userEmail , subject , html ) ;
173186 console . log ( `📧 Rich email notification sent to ${ userEmail } for ${ settings . full_name } ` ) ;
187+ } else {
188+ console . log ( `📧 Skipping email: notify_email=${ settings . notify_email } , userEmail=${ userEmail || 'NOT SET' } ` ) ;
174189 }
175190
176191 // Send Slack notification (basic for now)
0 commit comments