Skip to content
Snippets Groups Projects
Commit a005fe8f authored by David Planella's avatar David Planella
Browse files

Simplify fetching related MRs via API

parent d8886468
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -20,35 +20,15 @@ function setupHackathonCountdown() {
var hackathonIssueID = '14';
var apiHost = 'https://gitlab.com/api/v4';
var gitlabProjectID = '9821951';
var apiEndpoint = '/projects/' + gitlabProjectID + '/issues/' + hackathonIssueID + '/related_merge_requests';
var apiEndpoint = '/projects/' + gitlabProjectID
+ '/issues/' + hackathonIssueID + '/related_merge_requests';
var apiURL = apiHost + apiEndpoint;
 
const limitPerPage = 100;
const getRelatedMRs = async function(pageNo = 1) {
let apiPaginatedURL = apiURL + `?page=${pageNo}&per_page=${limitPerPage}`;
var apiResults = await fetch(apiPaginatedURL)
.then(resp=>{
return resp.json();
});
return apiResults;
}
const getAllRelatedMRs = async function(pageNo = 1) {
const results = await getRelatedMRs(pageNo);
if (results.length > 0) {
return results.concat(await getAllRelatedMRs(pageNo + 1));
} else {
return results;
}
};
(async ()=>{
const entireList = await getAllRelatedMRs();
var boxMessage = entireList.length + ' MRs submitted '
fetch(apiURL)
.then(function(response) {
var totalRelatedMRs = response.headers.get('X-Total');
var boxMessage = totalRelatedMRs + ' MRs submitted '
+ ' at the last Hackathon!';
document.getElementById('hackathonMRCount').innerHTML = boxMessage;
})();
\ No newline at end of file
})
.catch(error => console.error('Error:', error));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment