Add time filter pills to RSS feed widget

Adds since query param (1h/24h/7d/30d) to the RSS API route and
a matching TimeFilterPills row in the NewsFeed UI so users can
narrow the feed to recent items.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Shivam Patel
2026-02-09 17:25:39 -05:00
parent b9568c69a7
commit 717d52bd9a
2 changed files with 69 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ export async function GET(req: NextRequest) {
const q = searchParams.get('q');
const feedId = searchParams.get('feed_id');
const bookmarked = searchParams.get('bookmarked');
const since = searchParams.get('since');
const limit = parseInt(searchParams.get('limit') || '50', 10);
const offset = parseInt(searchParams.get('offset') || '0', 10);
@@ -27,6 +28,19 @@ export async function GET(req: NextRequest) {
if (bookmarked === '1') {
conditions.push('i.bookmarked = 1');
}
if (since) {
const sinceMap: Record<string, string> = {
'1h': '-1 hours',
'24h': '-24 hours',
'7d': '-7 days',
'30d': '-30 days',
};
const modifier = sinceMap[since];
if (modifier) {
conditions.push("i.pub_date >= datetime('now', ?)");
params.push(modifier);
}
}
const where = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';