-
Notifications
You must be signed in to change notification settings - Fork 15
/
getIssues.js
28 lines (26 loc) · 1.14 KB
/
getIssues.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
const { issueCardValues, groupValues } = require('./constants');
const { singleQuery } = require('../../baseQueries');
// GET all issues
const getIssues = async () => {
const queryText = `
SELECT
DISTINCT ON (issues.id)
${issueCardValues},
ARRAY_REMOVE(ARRAY_AGG(DISTINCT(languages.language)), NULL) AS language,
CASE WHEN pullrequests.merged = true THEN true ELSE false END AS "isPullRequestMerged",
COALESCE(funding.user_accepted, false) AS "isUserAccepted"
FROM issues
LEFT JOIN attempting ON attempting.issue_id = issues.id
LEFT JOIN comments ON comments.target = issues.id
LEFT JOIN funding ON funding.issue_id = issues.id
LEFT JOIN languages ON languages.issue_id = issues.id
LEFT JOIN pullrequests on pullrequests.issue_id = issues.id AND pullrequests.is_deleted = false
LEFT JOIN repos ON issues.repo_id = repos.id
LEFT JOIN watching ON watching.issue_id = issues.id
WHERE issues.is_deleted = false
GROUP BY ${groupValues}, funding.id, funding.is_approved, pullrequests.merged
`;
const { rows } = await singleQuery({ queryText });
return rows;
};
module.exports = getIssues;