Skip to content

Commit 9ba39a3

Browse files
committed
enable AI Review buddy
1 parent 4b7990b commit 9ba39a3

File tree

2 files changed

+165
-0
lines changed

2 files changed

+165
-0
lines changed

.github/workflows/code_reviewer.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: AI PR Reviewer
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
permissions:
9+
pull-requests: write
10+
jobs:
11+
tc-ai-pr-review:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repo
15+
uses: actions/checkout@v3
16+
17+
- name: TC AI PR Reviewer
18+
uses: topcoder-platform/tc-ai-pr-reviewer@master
19+
with:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The GITHUB_TOKEN is there by default so you just need to keep it like it is and not necessarily need to add it as secret as it will throw an error. [More Details](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret)
21+
LAB45_API_KEY: ${{ secrets.LAB45_API_KEY }}
22+
exclude: '**/*.json, **/*.md, **/*.jpg, **/*.png, **/*.jpeg, **/*.bmp, **/*.webp' # Optional: exclude patterns separated by commas

fix.txt

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
commit 4b5eecc32d6cf2e5b8f4bc00d1b56b27447e88ba
2+
Author: himaniraghav3 <[email protected]>
3+
Date: Thu Feb 27 14:33:45 2025 +0530
4+
5+
Add pagination to copilot opportunities response
6+
7+
diff --git a/src/routes/copilotOpportunity/get.js b/src/routes/copilotOpportunity/get.js
8+
index 9ceb6a57..a968af13 100644
9+
--- a/src/routes/copilotOpportunity/get.js
10+
+++ b/src/routes/copilotOpportunity/get.js
11+
@@ -1,9 +1,5 @@
12+
-import _ from 'lodash';
13+
-
14+
import models from '../../models';
15+
-import { ADMIN_ROLES } from '../../constants';
16+
import util from '../../util';
17+
-import { PERMISSION } from '../../permissions/constants';
18+
19+
module.exports = [
20+
(req, res, next) => {
21+
@@ -13,26 +9,26 @@ module.exports = [
22+
return util.handleError('Invalid opportunity ID', null, req, next, 400);
23+
}
24+
25+
- models.CopilotOpportunity.findOne({
26+
- where: { id },
27+
- include: [
28+
- {
29+
- model: models.CopilotRequest,
30+
- as: 'copilotRequest',
31+
- },
32+
- {
33+
- model: models.Project,
34+
- as: 'project',
35+
- attributes: ['name'],
36+
- }
37+
- ],
38+
+ return models.CopilotOpportunity.findOne({
39+
+ where: { id },
40+
+ include: [
41+
+ {
42+
+ model: models.CopilotRequest,
43+
+ as: 'copilotRequest',
44+
+ },
45+
+ {
46+
+ model: models.Project,
47+
+ as: 'project',
48+
+ attributes: ['name'],
49+
+ },
50+
+ ],
51+
})
52+
.then((copilotOpportunity) => {
53+
- const plainOpportunity = copilotOpportunity.get({ plain: true });
54+
- const formattedOpportunity = Object.assign({}, plainOpportunity,
55+
- plainOpportunity.copilotRequest ? plainOpportunity.copilotRequest.data : {},
56+
- { copilotRequest: undefined }
57+
- );
58+
+ const plainOpportunity = copilotOpportunity.get({ plain: true });
59+
+ const formattedOpportunity = Object.assign({}, plainOpportunity,
60+
+ plainOpportunity.copilotRequest ? plainOpportunity.copilotRequest.data : {},
61+
+ { copilotRequest: undefined },
62+
+ );
63+
res.json(formattedOpportunity);
64+
})
65+
.catch((err) => {
66+
diff --git a/src/routes/copilotOpportunity/list.js b/src/routes/copilotOpportunity/list.js
67+
index 1f1e003f..f8d45bde 100644
68+
--- a/src/routes/copilotOpportunity/list.js
69+
+++ b/src/routes/copilotOpportunity/list.js
70+
@@ -1,9 +1,7 @@
71+
import _ from 'lodash';
72+
73+
import models from '../../models';
74+
-import { ADMIN_ROLES } from '../../constants';
75+
import util from '../../util';
76+
-import { PERMISSION } from '../../permissions/constants';
77+
78+
module.exports = [
79+
(req, res, next) => {
80+
@@ -17,29 +15,42 @@ module.exports = [
81+
}
82+
const sortParams = sort.split(' ');
83+
84+
- models.CopilotOpportunity.findAll({
85+
- include: [
86+
- {
87+
- model: models.CopilotRequest,
88+
- as: 'copilotRequest',
89+
- },
90+
- {
91+
- model: models.Project,
92+
- as: 'project',
93+
- attributes: ['name'],
94+
- }
95+
- ],
96+
- order: [[sortParams[0], sortParams[1]]],
97+
+ // Extract pagination parameters
98+
+ const page = parseInt(req.query.page, 10) || 1;
99+
+ const pageSize = parseInt(req.query.pageSize, 10) || 10;
100+
+ const offset = (page - 1) * pageSize;
101+
+ const limit = pageSize;
102+
+
103+
+ return models.CopilotOpportunity.findAll({
104+
+ include: [
105+
+ {
106+
+ model: models.CopilotRequest,
107+
+ as: 'copilotRequest',
108+
+ },
109+
+ {
110+
+ model: models.Project,
111+
+ as: 'project',
112+
+ attributes: ['name'],
113+
+ },
114+
+ ],
115+
+ order: [[sortParams[0], sortParams[1]]],
116+
+ limit,
117+
+ offset,
118+
})
119+
- .then(copilotOpportunities => {
120+
- const formattedOpportunities = copilotOpportunities.map(opportunity => {
121+
- const plainOpportunity = opportunity.get({ plain: true });
122+
- return Object.assign({}, plainOpportunity,
123+
- plainOpportunity.copilotRequest ? plainOpportunity.copilotRequest.data : {},
124+
- { copilotRequest: undefined }
125+
- );
126+
+ .then((copilotOpportunities) => {
127+
+ const formattedOpportunities = copilotOpportunities.map((opportunity) => {
128+
+ const plainOpportunity = opportunity.get({ plain: true });
129+
+ return Object.assign({}, plainOpportunity,
130+
+ plainOpportunity.copilotRequest ? plainOpportunity.copilotRequest.data : {},
131+
+ { copilotRequest: undefined },
132+
+ );
133+
+ });
134+
+ return util.setPaginationHeaders(req, res, {
135+
+ count: copilotOpportunities.count,
136+
+ rows: formattedOpportunities,
137+
+ page,
138+
+ pageSize,
139+
});
140+
- return res.json(formattedOpportunities);
141+
})
142+
.catch((err) => {
143+
util.handleError('Error fetching copilot opportunities', err, req, next);

0 commit comments

Comments
 (0)