Skip to content

Commit 90bcc82

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
improve catch up
1 parent 8660cd6 commit 90bcc82

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

email/templates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (s *Sender) formatNotificationBody(sub *notifier.Subscription, thread *noti
1919
b.WriteString(".header { border-bottom: 2px solid #e67e22; padding-bottom: 10px; margin-bottom: 20px; }\n")
2020
b.WriteString(".post { margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid #ecf0f1; }\n")
2121
b.WriteString(".post:last-of-type { border-bottom: none; }\n")
22-
b.WriteString(".author { color: #e67e22; font-weight: 600; }\n")
22+
b.WriteString(".author { color: #e67e22; font-weight: 600; font-size: 1.2em; }\n")
2323
b.WriteString(".timestamp { color: #7f8c8d; font-size: 0.9em; }\n")
2424
b.WriteString(".content { background: #f8f9fa; padding: 20px; border-radius: 8px; margin: 15px 0; }\n")
2525
b.WriteString(".content img { max-width: 100%; height: auto; margin: 10px 0; display: block; }\n")

poll/poll.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"advrider-notifier/pkg/notifier"
1313
)
1414

15-
const maxPostsPerEmail = 5 // Safety limit: max posts to include in a single email
15+
const maxPostsPerEmail = 10 // Safety limit: max posts to include in a single email
1616

1717
// Scraper interface for fetching thread data.
1818
type Scraper interface {
@@ -374,6 +374,7 @@ func (m *Monitor) checkThreadForSubscribers(ctx context.Context, info *threadChe
374374

375375
if len(newPosts) > 0 {
376376
// Apply safety limit
377+
originalCount := len(newPosts)
377378
if len(newPosts) > maxPostsPerEmail {
378379
m.logger.Warn("Too many new posts, limiting to most recent",
379380
"cycle", m.cycleNumber,
@@ -385,13 +386,15 @@ func (m *Monitor) checkThreadForSubscribers(ctx context.Context, info *threadChe
385386
newPosts = newPosts[len(newPosts)-maxPostsPerEmail:]
386387
}
387388

388-
// Send notification
389+
// Send notification with all new posts in a single email
389390
m.logger.Info("Sending notification",
390391
"cycle", m.cycleNumber,
391392
"email", email,
392393
"thread_url", threadURL,
393394
"thread_title", thread.ThreadTitle,
394-
"new_posts", len(newPosts),
395+
"new_posts_count", len(newPosts),
396+
"original_count", originalCount,
397+
"capped", originalCount > maxPostsPerEmail,
395398
"previous_last_post", thread.LastPostID,
396399
"new_last_post", latestPost.ID)
397400

0 commit comments

Comments
 (0)