Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix:content search pagination (#681)

Bharadwajjjjj479b9bfc9839
diff --git a/server/src/routes/content.js b/server/src/routes/content.js
index 57a59f8ee..6e9fd16e5 100644
--- a/server/src/routes/content.js
+++ b/server/src/routes/content.js
@@ -129,7 +129,7 @@ router.get('/job/:jobId', async (req, res) => {
router.get('/brand/:brandId', async (req, res) => {
try {
const { brandId } = req.params;
- const { status, impact, type, limit = 50, offset = 0, sort = 'score' } = req.query;
+ const { status, impact, type, q, limit = 50, offset = 0, sort = 'score' } = req.query;
let query = supabaseAdmin
.from('content_opportunities')
@@ -140,6 +140,11 @@ router.get('/brand/:brandId', async (req, res) => {
if (impact) query = query.eq('impact', impact);
if (type) query = query.eq('type', type);
+ if (q) {
+ const search = String(q).replace(/[,()]/g, ' ');
+ query = query.or(`title.ilike.%${search}%,description.ilike.%${search}%`);
+ }
+
if (sort === 'score') {
query = query.order('opportunity_score', { ascending: false });
} else if (sort === 'newest') {
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
index 6f582b740..ecb975cf3 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
@@ -162,11 +162,15 @@ export default function ContentPage() {
const [webhookOpen, setWebhookOpen] = useState(false);
const pollRef = useRef(false);
+ const [debouncedSearch, setDebouncedSearch] = useState(search);
// Server-side paging (#610) — the list can hold far more than one page's
// worth of opportunities, so `total` (the exact server count) drives the
// pager instead of the length of whatever page happens to be loaded.
- const pager = usePagination(total, `${statusFilter}|${impactFilter}|${typeFilter}`);
+ const pager = usePagination(
+ total,
+ `${statusFilter}|${impactFilter}|${typeFilter}|${debouncedSearch}`,
+ );
const loadData = useCallback(
async (silent = false, isCancelled?: () => boolean) => {
@@ -184,6 +188,9 @@ export default function ContentPage() {
if (statusFilter !== 'all') filters.status = statusFilter;
if (impactFilter !== 'all') filters.impact = impactFilter;
if (typeFilter !== 'all') filters.type = typeFilter;
+ if (debouncedSearch.trim()) {
+ filters.q = debouncedSearch.trim();
+ }
const data = await getOpportunities(activeBrandId, {
...filters,
@@ -205,9 +212,17 @@ export default function ContentPage() {
}
}
},
- [activeBrandId, statusFilter, impactFilter, typeFilter, pager.start],
+ [activeBrandId, statusFilter, impactFilter, typeFilter, pager.start, debouncedSearch],
);
+ useEffect(() => {
+ const timer = setTimeout(() => {
+ setDebouncedSearch(search);
+ }, 300);
+
+ return () => clearTimeout(timer);
+ }, [search]);
+
useEffect(() => {
let cancelled = false;
diff --git a/web/src/lib/actions/content.ts b/web/src/lib/actions/content.ts
index 2f67f8b9d..ee9caff5e 100644
--- a/web/src/lib/actions/content.ts
+++ b/web/src/lib/actions/content.ts
@@ -81,6 +81,7 @@ export async function getOpportunities(
filters?: {
status?: string;
impact?: string;
+ q?: string;
type?: string;
limit?: number;
offset?: number;
@@ -92,6 +93,7 @@ export async function getOpportunities(
const params = new URLSearchParams();
if (filters?.status) params.set('status', filters.status);
if (filters?.impact) params.set('impact', filters.impact);
+ if (filters?.q) params.set('q', filters.q);
if (filters?.type) params.set('type', filters.type);
if (filters?.limit) params.set('limit', String(filters.limit));
if (filters?.offset) params.set('offset', String(filters.offset));