This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetchIssues.js
47 lines (43 loc) · 1.72 KB
/
fetchIssues.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const axios = require('axios');
async function callApi() {
var issuesList = [];
try {
var repositories = await axios.get('https://raw.githubusercontent.com/ARK-Builders/cache-project-issues/main/repos-list.json');
if (repositories.status === 200) {
repositories = repositories.data;
for (const repo of repositories) {
const issues = await axios.get('https://api.github.com/repos/ARK-Builders/'+repo.name+'/issues');
if (issues.status === 200) {
if(issues.data.length > 0){
for (const issue of issues.data) {
var repoUrl = issue.repository_url.replace('api.','').replace('repos/','')
const assignees = issue.assignees.map(element => element.login);
const labels = issue.labels.map(element => element.name);
if(assignees.length == 0 && issue.state == 'open'){
issuesList.push({
title: issue.title,
labels: labels.filter(item => item == 'bug' || item == 'good first issue' || item == 'feature' || item == 'enhancement'),
user: issue.user.login,
user_avatar: issue.user.avatar_url,
date: new Date(issue.created_at),
repo: repoUrl,
number: issue.number,
platforms:repo.platforms,
languages:repo.languages
})
}
}
}
} else {
throw new Error(`API request failed with status ${response.status}`);
}
}
return issuesList;
} else {
throw new Error(`API request failed with status ${response.status}`);
}
} catch (error) {
throw error;
}
}
module.exports = callApi;