Database creation script fixed
A view was used before it was created.
This commit is contained in:
parent
1423434dfd
commit
8bf2034ba6
3 changed files with 42 additions and 41 deletions
|
@ -16,5 +16,6 @@ BEGIN;
|
||||||
-- Task management and task dependencies
|
-- Task management and task dependencies
|
||||||
\i database/tasks-functions.sql
|
\i database/tasks-functions.sql
|
||||||
\i database/task-dependencies.sql
|
\i database/task-dependencies.sql
|
||||||
|
\i database/tasks-view.sql
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
|
@ -78,44 +78,3 @@ END;
|
||||||
$update_task$ LANGUAGE plpgsql;
|
$update_task$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Task list view
|
|
||||||
--
|
|
||||||
-- This view contains all fields used to display task lists.
|
|
||||||
--
|
|
||||||
|
|
||||||
DROP VIEW IF EXISTS tasks_list;
|
|
||||||
CREATE VIEW tasks_list
|
|
||||||
AS SELECT t.task_id AS id, t.item_id AS item, t.task_title AS title,
|
|
||||||
t.task_description AS description, t.task_added AS added_at,
|
|
||||||
u1.user_view_name AS added_by,
|
|
||||||
ct.completed_task_time AS completed_at,
|
|
||||||
u2.user_view_name AS completed_by ,
|
|
||||||
t.task_priority AS priority ,
|
|
||||||
bd.bad_deps AS missing_dependencies ,
|
|
||||||
mtd.trans_missing AS total_missing_dependencies
|
|
||||||
FROM tasks t
|
|
||||||
INNER JOIN users_view u1 ON u1.user_id = t.user_id
|
|
||||||
LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id
|
|
||||||
LEFT OUTER JOIN users_view u2 ON u2.user_id = ct.user_id
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT td.task_id , COUNT(*) AS bad_deps
|
|
||||||
FROM task_dependencies td
|
|
||||||
LEFT OUTER JOIN completed_tasks dct
|
|
||||||
ON dct.task_id = td.task_id_depends
|
|
||||||
WHERE dct.task_id IS NULL
|
|
||||||
GROUP BY td.task_id
|
|
||||||
) AS bd ON bd.task_id = t.task_id
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT tdn.task_id , COUNT( DISTINCT task_id_copyof ) AS trans_missing
|
|
||||||
FROM taskdep_nodes tdn
|
|
||||||
LEFT OUTER JOIN completed_tasks ct
|
|
||||||
ON ct.task_id = task_id_copyof
|
|
||||||
WHERE NOT tnode_reverse AND ct.task_id IS NULL
|
|
||||||
AND tdn.task_id <> tdn.task_id_copyof
|
|
||||||
GROUP BY tdn.task_id
|
|
||||||
) AS mtd ON mtd.task_id = t.task_id;
|
|
||||||
|
|
||||||
GRANT SELECT ON tasks_list TO :webapp_user;
|
|
||||||
|
|
||||||
|
|
41
database/tasks-view.sql
Normal file
41
database/tasks-view.sql
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
--
|
||||||
|
-- Task list view
|
||||||
|
--
|
||||||
|
-- This view contains all fields used to display task lists.
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP VIEW IF EXISTS tasks_list;
|
||||||
|
CREATE VIEW tasks_list
|
||||||
|
AS SELECT t.task_id AS id, t.item_id AS item, t.task_title AS title,
|
||||||
|
t.task_description AS description, t.task_added AS added_at,
|
||||||
|
u1.user_view_name AS added_by,
|
||||||
|
ct.completed_task_time AS completed_at,
|
||||||
|
u2.user_view_name AS completed_by ,
|
||||||
|
t.task_priority AS priority ,
|
||||||
|
bd.bad_deps AS missing_dependencies ,
|
||||||
|
mtd.trans_missing AS total_missing_dependencies
|
||||||
|
FROM tasks t
|
||||||
|
INNER JOIN users_view u1 ON u1.user_id = t.user_id
|
||||||
|
LEFT OUTER JOIN completed_tasks ct ON ct.task_id = t.task_id
|
||||||
|
LEFT OUTER JOIN users_view u2 ON u2.user_id = ct.user_id
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT td.task_id , COUNT(*) AS bad_deps
|
||||||
|
FROM task_dependencies td
|
||||||
|
LEFT OUTER JOIN completed_tasks dct
|
||||||
|
ON dct.task_id = td.task_id_depends
|
||||||
|
WHERE dct.task_id IS NULL
|
||||||
|
GROUP BY td.task_id
|
||||||
|
) AS bd ON bd.task_id = t.task_id
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT tdn.task_id , COUNT( DISTINCT task_id_copyof ) AS trans_missing
|
||||||
|
FROM taskdep_nodes tdn
|
||||||
|
LEFT OUTER JOIN completed_tasks ct
|
||||||
|
ON ct.task_id = task_id_copyof
|
||||||
|
WHERE NOT tnode_reverse AND ct.task_id IS NULL
|
||||||
|
AND tdn.task_id <> tdn.task_id_copyof
|
||||||
|
GROUP BY tdn.task_id
|
||||||
|
) AS mtd ON mtd.task_id = t.task_id;
|
||||||
|
|
||||||
|
GRANT SELECT ON tasks_list TO :webapp_user;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue