Skip to content

Commit 107c6ca

Browse files
fix(codevs): standardize accepted developer filter and correct accept-flow role assignment
1 parent bd01b41 commit 107c6ca

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎apps/codebility/app/(marketing)/codevs/_components/CodevsProfiles.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const revalidate = 0;
1515

1616
export default async function CodevsProfiles() {
1717
const [{ data: allCodevs, error }] = await Promise.all([
18-
getCodevs({ filters: { role_id: 10 } }), // show only Codevs with role_id 10 which is Codev
18+
getCodevs({ filters: { application_status: "passed" } }), // show only accepted Codevs (application_status is the source of truth)
1919
]);
2020

2121
if (error) {

‎apps/codebility/app/home/applicants/_service/action.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export async function acceptApplicantAction(applicantId: string) {
275275
.from("codev")
276276
.update({
277277
application_status: "passed",
278-
role_id: 4,
278+
role_id: 10,
279279
date_joined: new Date().toISOString(),
280280
updated_at: new Date().toISOString()
281281
})
@@ -305,7 +305,7 @@ export async function multipleAcceptApplicantAction(applicantIds: string[]) {
305305
.from("codev")
306306
.update({
307307
application_status: "passed",
308-
role_id: 4,
308+
role_id: 10,
309309
date_joined: new Date().toISOString(),
310310
updated_at: new Date().toISOString()
311311
})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- =============================================================================
2+
-- Fix role_id for accepted developers
3+
--
4+
-- The accept flow was incorrectly assigning role_id: 4 (Super Admin/Intern)
5+
-- instead of role_id: 10 (Codev). This migration:
6+
-- 1. Fixes existing accepted devs who have role_id 4 → set them to role_id 10
7+
-- 2. Does NOT touch role_id 1 (Admin) users — they stay as Admin
8+
-- 3. Only affects rows where application_status = 'passed'
9+
--
10+
-- Role ID mapping (confirmed from codebase usage):
11+
-- 1 = Admin
12+
-- 4 = Super Admin / Intern (over-privileged, was assigned by mistake in accept flow)
13+
-- 5 = Mentor
14+
-- 7 = Applicant
15+
-- 10 = Codev (intended role for accepted developers)
16+
-- =============================================================================
17+
18+
-- Fix existing accepted developers who were given the wrong role
19+
UPDATE public.codev
20+
SET role_id = 10,
21+
updated_at = NOW()
22+
WHERE application_status = 'passed'
23+
AND role_id = 4;
24+
25+
-- Log what was changed
26+
SELECT 'Fixed role_id for accepted devs' AS action,
27+
COUNT(*) AS rows_affected
28+
FROM public.codev
29+
WHERE application_status = 'passed'
30+
AND role_id = 10;

0 commit comments

Comments
 (0)