Commit c37fb8da authored by David Planella's avatar David Planella

Reworked Hackathon page layout, added MR counter

parent a327be7c
Pipeline #63082970 passed with stages
in 26 minutes and 42 seconds
This diff is collapsed.
......@@ -10,3 +10,42 @@ function setupHackathonCountdown() {
setupHackathonCountdown();
})();
// Use the GitLab API to fetch the number of MRs submitted during the Hackathon
// It assumes there is a tracking issue that contains the list of MRs as
// related merge requests
// Hackathon tracker issue. Update the issue ID for each Hackathon
// E.g. on https://gitlab.com/gitlab-com/marketing/community-relations/contributor-program/hackathon/issues/18
// the issue ID is '18'
var hackathonIssueID = '14';
var apiHost = 'https://gitlab.com/api/v4';
var gitlabProjectID = '9821951';
var apiEndpoint = '/projects/' + gitlabProjectID + '/issues/' + hackathonIssueID + '/related_merge_requests';
// TODO: needs pagination
var apiPagination = '?per_page=100';
var apiURL = apiHost + apiEndpoint + apiPagination;
var request = new XMLHttpRequest();
request.open('GET', apiURL, true);
request.onload = function () {
var data = JSON.parse(this.response);
var mrCount = 0;
var boxMessage = '';
if (request.status >= 200 && request.status < 400) {
data.forEach(mr => {
mrCount += 1;
});
boxMessage = mrCount + ' MRs submitted '
+ ' at the last Hackathon ';
} else {
boxMessage = 'Error fetching merge requests';
}
document.getElementById('hackathonMRCount').innerHTML = boxMessage;
}
request.send();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment