Commit 656cead5 authored by Leo Gordon's avatar Leo Gordon
Browse files

start using procedures.pgsql with two main views ("progress" and "msg")

parent d14eca7d
......@@ -135,9 +135,10 @@ sub pipeline_create_commands {
$self->o('hive_force_init') ? ( $self->db_execute_command($db_conn, 'DROP DATABASE IF EXISTS '.$self->o($db_conn, '-dbname'), 0 ) ) : (),
$self->db_execute_command($db_conn, 'CREATE DATABASE '.$self->o($db_conn, '-dbname'), 0 ),
# standard eHive tables, triggers, foreign_keys and procedures:
# standard eHive tables, foreign_keys and procedures:
$self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/tables.pgsql',
$self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/foreign_keys.sql',
$self->db_connect_command($db_conn).' <'.$self->o('hive_root_dir').'/sql/procedures.pgsql',
],
}->{ $self->o($db_conn, '-driver') };
......
-- ------------------------------------------------------------------------
--
-- Some stored functions, views and procedures used in hive:
--
-- show hive progress for analyses (turned into a view to give extra flexibility) ----------------
--
-- Thanks to Greg Jordan for the idea and the original version
--
-- Usage:
-- select * from progress; # the whole table (may take ages to generate, depending on the size of your pipeline)
-- select * from progress where logic_name like 'family_blast%'; # only show family_blast-related analyses
-- select * from progress where retry_count>1; # only show jobs that have been tried more than once
CREATE OR REPLACE VIEW progress AS
SELECT a.logic_name || '(' || a.analysis_id || ')' analysis_name_and_id,
MIN(rc.name) resource_class,
j.status,
j.retry_count,
CASE WHEN j.status IS NULL THEN 0 ELSE count(*) END cnt,
MIN(job_id) example_job_id
FROM analysis_base a
LEFT JOIN job j USING (analysis_id)
LEFT JOIN resource_class rc ON (a.resource_class_id=rc.resource_class_id)
GROUP BY a.analysis_id, j.status, j.retry_count
ORDER BY a.analysis_id, j.status;
-- a convenient view that also incorporates (otherwise redundant) analysis_id and logic_name ------------
--
-- Usage:
-- select * from msg;
-- select * from msg where analysis_id=18;
-- select * from msg where logic_name like 'family_blast%';
CREATE OR REPLACE VIEW msg AS
SELECT a.analysis_id, a.logic_name, m.*
FROM log_message m
JOIN worker w USING (worker_id)
LEFT JOIN job j ON (j.job_id=m.job_id)
LEFT JOIN analysis_base a ON (a.analysis_id=j.analysis_id);
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