KrishnaCosmic commited on
Commit
4efd4f9
·
1 Parent(s): 229d06d

bug fix 43

Browse files
src/app/api/contributor/my-issues/route.ts CHANGED
@@ -20,9 +20,28 @@ export async function GET(request: NextRequest) {
20
  const { searchParams } = new URL(request.url);
21
  const page = parseInt(searchParams.get("page") || "1");
22
  const limit = parseInt(searchParams.get("limit") || "10");
 
 
23
 
24
- // Get issues from database
25
- const issuesData = await getIssuesWithTriage({ authorName: user.username }, page, limit);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  // If database has results, return them
28
  if (issuesData.total > 0) {
 
20
  const { searchParams } = new URL(request.url);
21
  const page = parseInt(searchParams.get("page") || "1");
22
  const limit = parseInt(searchParams.get("limit") || "10");
23
+ const isPRParam = searchParams.get("isPR");
24
+ const repoParam = searchParams.get("repo");
25
 
26
+ // Build filters
27
+ const filters: { authorName: string; isPR?: boolean; repoName?: string } = {
28
+ authorName: user.username
29
+ };
30
+
31
+ // Add isPR filter if specified
32
+ if (isPRParam === 'true') {
33
+ filters.isPR = true;
34
+ } else if (isPRParam === 'false') {
35
+ filters.isPR = false;
36
+ }
37
+
38
+ // Add repo filter if specified
39
+ if (repoParam && repoParam !== 'all') {
40
+ filters.repoName = repoParam;
41
+ }
42
+
43
+ // Get issues from database with filters
44
+ const issuesData = await getIssuesWithTriage(filters, page, limit);
45
 
46
  // If database has results, return them
47
  if (issuesData.total > 0) {
src/lib/db/queries/issues.ts CHANGED
@@ -70,6 +70,7 @@ export async function updateIssueState(id: string, state: string) {
70
 
71
  export interface IssueFilters {
72
  repoId?: string;
 
73
  userId?: string;
74
  authorName?: string;
75
  state?: string;
@@ -83,6 +84,7 @@ export async function getIssues(filters: IssueFilters, page = 1, limit = 10) {
83
  // Build conditions
84
  const conditions = [];
85
  if (filters.repoId) conditions.push(eq(issues.repoId, filters.repoId));
 
86
  if (filters.authorName) conditions.push(eq(issues.authorName, filters.authorName));
87
  if (filters.state) conditions.push(eq(issues.state, filters.state));
88
  if (filters.isPR !== undefined) conditions.push(eq(issues.isPR, filters.isPR));
 
70
 
71
  export interface IssueFilters {
72
  repoId?: string;
73
+ repoName?: string; // Filter by repo name (owner/repo format)
74
  userId?: string;
75
  authorName?: string;
76
  state?: string;
 
84
  // Build conditions
85
  const conditions = [];
86
  if (filters.repoId) conditions.push(eq(issues.repoId, filters.repoId));
87
+ if (filters.repoName) conditions.push(eq(issues.repoName, filters.repoName));
88
  if (filters.authorName) conditions.push(eq(issues.authorName, filters.authorName));
89
  if (filters.state) conditions.push(eq(issues.state, filters.state));
90
  if (filters.isPR !== undefined) conditions.push(eq(issues.isPR, filters.isPR));