Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 1 addition & 33 deletions middlewares/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,7 @@ async function getProjectDependencies(req, res, next) {
const params = matchedData(req);

const { id } = params;
const query = `
SELECT
d.id AS dep_id,
d.upstream AS dep_up,
d.downstream AS dep_down,
d.active AS dep_active,
p.id AS project_id,
p.name AS project_name,
p.status AS project_status,
p.priority AS project_priority,
COALESCE(js.ready, 0) AS ready,
COALESCE(js.done, 0) AS done,
COALESCE(js.waiting, 0) AS waiting,
COALESCE(js.running, 0) AS running,
COALESCE(js.failed, 0) AS failed,
COALESCE(js.total, 0) AS total
FROM public.projectdependencies d
JOIN public.projects p ON p.id = d.upstream
LEFT JOIN LATERAL (
SELECT
COUNT(*) FILTER (WHERE j.status = 'ready') AS ready,
COUNT(*) FILTER (WHERE j.status = 'done') AS done,
COUNT(*) FILTER (WHERE j.status = 'waiting') AS waiting,
COUNT(*) FILTER (WHERE j.status = 'running') AS running,
COUNT(*) FILTER (WHERE j.status = 'failed') AS failed,
COUNT(*) AS total
FROM public.jobs j
WHERE j.id_project = p.id
) js ON TRUE
WHERE d.downstream = $1
`;

await req.client.query(query, [id])
await req.client.query('SELECT * FROM view_project_dependencies WHERE dep_down=$1', [id])
.then((results) => { req.result = results.rows; })
.catch((error) => {
req.error = {
Expand Down
Loading