File tree Expand file tree Collapse file tree 3 files changed +34
-12
lines changed Expand file tree Collapse file tree 3 files changed +34
-12
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ const getUserPRs = async (req, res) => {
37
37
*/
38
38
const getStalePRs = async ( req , res ) => {
39
39
try {
40
- const { data } = await githubService . fetchStalePRs ( )
40
+ const { size, page } = req . query
41
+ const { data } = await githubService . fetchStalePRs ( size , page )
41
42
42
43
if ( data . total_count ) {
43
44
const allPRs = githubService . extractPRdetails ( data )
@@ -65,7 +66,8 @@ const getStalePRs = async (req, res) => {
65
66
*/
66
67
const getOpenPRs = async ( req , res ) => {
67
68
try {
68
- const { data } = await githubService . fetchOpenPRs ( ( req . query . page ) || 1 )
69
+ const { size, page } = req . query
70
+ const { data } = await githubService . fetchOpenPRs ( size , page )
69
71
70
72
if ( data . total_count ) {
71
73
const allPRs = githubService . extractPRdetails ( data )
Original file line number Diff line number Diff line change @@ -9,6 +9,17 @@ const pullRequest = require('../controllers/pullRequests')
9
9
* summary: Latest 10 Pull Requests in Real Dev Squad
10
10
* tags:
11
11
* - Pull Requests
12
+ * parameters:
13
+ * - in: query
14
+ * name: size
15
+ * schema:
16
+ * type: integer
17
+ * description: Number of pull requests to be returned
18
+ * - in: query
19
+ * name: page
20
+ * schema:
21
+ * type: integer
22
+ * description: Page number for pagination
12
23
* responses:
13
24
* 200:
14
25
* description: Pull Requests
@@ -40,6 +51,17 @@ router.get('/open', pullRequest.getOpenPRs)
40
51
* summary: All open Pull Requests in Real Dev Squad
41
52
* tags:
42
53
* - Pull Requests
54
+ * parameters:
55
+ * - in: query
56
+ * name: size
57
+ * schema:
58
+ * type: integer
59
+ * description: Number of pull requests to be returned
60
+ * - in: query
61
+ * name: page
62
+ * schema:
63
+ * type: integer
64
+ * description: Page number for pagination
43
65
* responses:
44
66
* 200:
45
67
* description: Pull Requests
Original file line number Diff line number Diff line change @@ -99,18 +99,17 @@ const fetchPRsByUser = async (username) => {
99
99
}
100
100
101
101
/**
102
- * Fetches the oldest open N requests
103
- * @todo fetch N from query params
102
+ * Fetches the oldest open `per_page` requests
104
103
*/
105
- const fetchStalePRs = async ( ) => {
104
+ const fetchStalePRs = async ( per_page = 10 , page = 1 ) => {
106
105
try {
107
106
const url = getGithubURL ( {
108
107
is : 'open'
109
108
} , {
110
109
sort : 'created' ,
111
110
order : 'asc' ,
112
- per_page : 5 ,
113
- page : 1
111
+ per_page,
112
+ page
114
113
} )
115
114
return getFetch ( url )
116
115
} catch ( err ) {
@@ -120,18 +119,17 @@ const fetchStalePRs = async () => {
120
119
}
121
120
122
121
/**
123
- * Fetches the latest 10 open PRs
124
- * @todo fetch N from query params
122
+ * Fetches the latest `per_page` open PRs
125
123
*/
126
- const fetchOpenPRs = async ( pageNumber ) => {
124
+ const fetchOpenPRs = async ( per_page = 10 , page = 1 ) => {
127
125
try {
128
126
const url = getGithubURL ( {
129
127
is : 'open'
130
128
} , {
131
129
sort : 'created' ,
132
130
order : 'desc' ,
133
- per_page : 10 ,
134
- page : pageNumber
131
+ per_page,
132
+ page
135
133
} )
136
134
return getFetch ( url )
137
135
} catch ( err ) {
You can’t perform that action at this time.
0 commit comments