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:
@@ -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 ')}` : '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user