Skip to content

Commit 110310d

Browse files
Zeff01claude
andcommitted
feat: filter out inactive admins from client tracker
- Add explicit filter to exclude INACTIVE admins from client tracker view - Fetch internal_status field to enable proper filtering - Update migration script to include job_link column migration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a614a16 commit 110310d

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

‎apps/codebility/app/home/admin-controls/client-tracker/actions.ts‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ export async function getAdminOutreachStats(): Promise<{
5858
// Get all admins (excluding inactive ones)
5959
const { data: admins, error: adminsError } = await supabase
6060
.from('codev')
61-
.select('id, first_name, last_name, email_address')
61+
.select('id, first_name, last_name, email_address, internal_status')
6262
.eq('role_id', 1)
6363
.eq('application_status', 'passed')
64-
.neq('internal_status', 'INACTIVE')
6564
.order('first_name');
6665

6766
if (adminsError) {
@@ -98,15 +97,17 @@ export async function getAdminOutreachStats(): Promise<{
9897
return acc;
9998
}, {} as Record<string, number>) || {};
10099

101-
// Combine data
102-
const stats: AdminOutreachStats[] = admins?.map(admin => ({
103-
admin_id: admin.id,
104-
first_name: admin.first_name,
105-
last_name: admin.last_name,
106-
email_address: admin.email_address,
107-
current_week_count: currentWeekCounts[admin.id] || 0,
108-
total_count: totalCounts[admin.id] || 0,
109-
})) || [];
100+
// Combine data and filter out INACTIVE admins
101+
const stats: AdminOutreachStats[] = admins
102+
?.filter(admin => admin.internal_status !== 'INACTIVE')
103+
.map(admin => ({
104+
admin_id: admin.id,
105+
first_name: admin.first_name,
106+
last_name: admin.last_name,
107+
email_address: admin.email_address,
108+
current_week_count: currentWeekCounts[admin.id] || 0,
109+
total_count: totalCounts[admin.id] || 0,
110+
})) || [];
110111

111112
return { success: true, data: stats };
112113
} catch (error) {

‎apps/codebility/scripts/apply-pending-migrations.sql‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33
-- Run this SQL in Supabase SQL Editor
44
-- ========================================
55

6-
-- Migration 1: Add conversation_image column
6+
-- Migration 1: Add job_link column
7+
-- File: 20260220_add_job_link_to_client_outreach.sql
8+
ALTER TABLE public.client_outreach
9+
ADD COLUMN IF NOT EXISTS job_link TEXT;
10+
11+
COMMENT ON COLUMN public.client_outreach.job_link IS 'Optional URL to the job posting or opportunity related to this outreach';
12+
13+
-- Migration 2: Add conversation_image column
714
-- File: 20260223_add_conversation_image_to_client_outreach.sql
815
ALTER TABLE public.client_outreach
916
ADD COLUMN IF NOT EXISTS conversation_image TEXT;
1017

1118
COMMENT ON COLUMN public.client_outreach.conversation_image IS 'URL or base64 data of conversation screenshot with the client';
1219

13-
-- Migration 2: Make client_name optional
20+
-- Migration 3: Make client_name optional
1421
-- File: 20260224_make_client_name_optional.sql
1522
ALTER TABLE public.client_outreach
1623
ALTER COLUMN client_name DROP NOT NULL;

0 commit comments

Comments
 (0)