Spaces:
Sleeping
Sleeping
Commit ·
b6b16e1
1
Parent(s): e9b2cbc
changes
Browse files
src/app/api/contributor/track-repo/route.ts
CHANGED
|
@@ -102,6 +102,10 @@ export async function POST(request: NextRequest) {
|
|
| 102 |
|
| 103 |
if (existingRepoEntry[0]) {
|
| 104 |
repoId = existingRepoEntry[0].id;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
} else {
|
| 106 |
repoId = uuidv4();
|
| 107 |
await db.insert(repositories).values({
|
|
@@ -110,6 +114,7 @@ export async function POST(request: NextRequest) {
|
|
| 110 |
name: repoFullName,
|
| 111 |
owner: owner,
|
| 112 |
userId: user.id,
|
|
|
|
| 113 |
createdAt: new Date().toISOString(),
|
| 114 |
}).onConflictDoNothing();
|
| 115 |
}
|
|
@@ -163,7 +168,7 @@ export async function POST(request: NextRequest) {
|
|
| 163 |
}
|
| 164 |
|
| 165 |
return NextResponse.json({
|
| 166 |
-
message: prsFound > 0
|
| 167 |
? `Repository tracked! Found ${prsFound} open PR(s).`
|
| 168 |
: "Repository tracked successfully!",
|
| 169 |
repoFullName,
|
|
|
|
| 102 |
|
| 103 |
if (existingRepoEntry[0]) {
|
| 104 |
repoId = existingRepoEntry[0].id;
|
| 105 |
+
// Ensure it's marked as user-tracked so it appears in tracked-repos
|
| 106 |
+
await db.update(repositories)
|
| 107 |
+
.set({ addedByUser: true })
|
| 108 |
+
.where(eq(repositories.id, repoId));
|
| 109 |
} else {
|
| 110 |
repoId = uuidv4();
|
| 111 |
await db.insert(repositories).values({
|
|
|
|
| 114 |
name: repoFullName,
|
| 115 |
owner: owner,
|
| 116 |
userId: user.id,
|
| 117 |
+
addedByUser: true,
|
| 118 |
createdAt: new Date().toISOString(),
|
| 119 |
}).onConflictDoNothing();
|
| 120 |
}
|
|
|
|
| 168 |
}
|
| 169 |
|
| 170 |
return NextResponse.json({
|
| 171 |
+
message: prsFound > 0
|
| 172 |
? `Repository tracked! Found ${prsFound} open PR(s).`
|
| 173 |
: "Repository tracked successfully!",
|
| 174 |
repoFullName,
|