Skip to content

Commit efb4fc5

Browse files
committed
Add debug logging to recent edits to diagnose filtering issue
1 parent 7b3ed17 commit efb4fc5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

app/api/recent-edits/route.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ export async function GET(request: NextRequest) {
254254
const migrationTimeWindow = new Date('2025-07-28T14:56:00.000Z'); // Migration happened around this time
255255
const isInMigrationWindow = Math.abs(pageLastModified.getTime() - migrationTimeWindow.getTime()) < (10 * 60 * 1000); // Within 10 minutes
256256

257+
// Debug logging for first few pages
258+
if (validEdits.length < 5) {
259+
console.log(`🔍 [RECENT_EDITS] Processing ${page.title}:`, {
260+
pageLastModified: pageLastModified.toISOString(),
261+
versionCreatedAt: versionCreatedAt.toISOString(),
262+
timeDiffHours: timeDiffHours.toFixed(1),
263+
isInMigrationWindow,
264+
willSkip: isInMigrationWindow && timeDiffHours > 24
265+
});
266+
}
267+
257268
// Only skip if BOTH conditions are true:
258269
// 1. Page was modified in the migration time window
259270
// 2. The latest version is much older (indicating no real recent content)
@@ -342,6 +353,16 @@ export async function GET(request: NextRequest) {
342353
validEdits.length = 0;
343354
}
344355

356+
// Debug logging before sorting
357+
console.log(`🔍 [RECENT_EDITS] Before sorting - validEdits count: ${validEdits.length}`);
358+
if (validEdits.length > 0) {
359+
console.log(`🔍 [RECENT_EDITS] First few edits:`, validEdits.slice(0, 3).map(edit => ({
360+
title: edit.title,
361+
lastModified: edit.lastModified,
362+
source: edit.source
363+
})));
364+
}
365+
345366
// Sort by actual edit timestamp (version createdAt, not page lastModified which was affected by migration)
346367
const sortedEdits = validEdits
347368
.sort((a, b) => {
@@ -352,6 +373,8 @@ export async function GET(request: NextRequest) {
352373
})
353374
.slice(0, limit);
354375

376+
console.log(`🔍 [RECENT_EDITS] After sorting - sortedEdits count: ${sortedEdits.length}`);
377+
355378
// Fetch subscription data for all unique user IDs
356379
const uniqueUserIds = [...new Set(sortedEdits.map(edit => edit.userId).filter(Boolean))];
357380
const batchUserData = await fetchBatchUserData(uniqueUserIds, db);

0 commit comments

Comments
 (0)