diff --git a/Engineer/prep/base/projects.sql b/Engineer/prep/base/projects.sql index 2d92689..18fdd84 100644 --- a/Engineer/prep/base/projects.sql +++ b/Engineer/prep/base/projects.sql @@ -8,6 +8,7 @@ SELECT id AS project_id , modified AS modified_at , DATE(modified) AS modified_date , creator_id + , name , CASE WHEN _sdc_deleted_at IS NULL THEN FALSE ELSE TRUE END AS is_deleted_project diff --git a/Engineer/prep/intermediate/full_project_history.sql b/Engineer/prep/intermediate/full_project_history.sql index ce7d6c3..739df5f 100644 --- a/Engineer/prep/intermediate/full_project_history.sql +++ b/Engineer/prep/intermediate/full_project_history.sql @@ -1,5 +1,6 @@ SELECT history.project_id , projects.creator_id -- history table does not have a project creator id field + , projects.name , history.project_type , history.project_status , history.previous_project_status @@ -12,6 +13,10 @@ SELECT history.project_id END) OVER (PARTITION BY history.project_id) AS first_paused_date , RANK() OVER (PARTITION BY history.project_id ORDER BY history.project_history_id DESC) AS history_sequence + , max(case when history.project_status = 'Complete' + then history.modified_date + else null + end) over (partition by history.project_id) as last_completed_date , projects.project_deleted_date FROM {{ ref('project_history') }} AS history JOIN {{ ref('projects') }} AS projects ON projects.project_id = history.project_id \ No newline at end of file diff --git a/Engineer/prod/current_project_summary.sql b/Engineer/prod/current_project_summary.sql index e035c33..2afa326 100644 --- a/Engineer/prod/current_project_summary.sql +++ b/Engineer/prod/current_project_summary.sql @@ -1,21 +1,30 @@ SELECT full_project_history.project_id , full_project_history.creator_id + , full_project_history.name , full_project_history.project_type , full_project_history.project_status , full_project_history.previous_project_status , full_project_history.created_date , full_project_history.first_active_date + , DATEADD(DAY, -1, DATE_TRUNC(WEEK, DATE(full_project_history.first_active_date))) first_active_week , full_project_history.first_paused_date - , COUNT(full_task_history.task_id) AS number_of_tasks + , DATEADD(DAY, -1, DATE_TRUNC(WEEK, DATE(full_project_history.first_paused_date))) first_paused_week + , full_project_history.last_completed_date + , COUNT(full_task_history.task_id) AS number_of_tasks, + count(case when full_task_history.task_status = 'IN_PROGRESS' then 1 end) num_in_progress_tasks FROM {{ ref('full_project_history') }} AS full_project_history JOIN {{ ref('full_task_history') }} AS full_task_history ON full_task_history.project_id = full_project_history.project_id WHERE full_project_history.history_sequence = 1 AND full_task_history.history_sequence = 1 GROUP BY full_project_history.project_id , full_project_history.creator_id + , full_project_history.name , full_project_history.project_type , full_project_history.project_status , full_project_history.previous_project_status , full_project_history.created_date , full_project_history.first_active_date - , full_project_history.first_paused_date \ No newline at end of file + , first_active_week + , full_project_history.first_paused_date + , first_paused_week + , full_project_history.last_completed_date \ No newline at end of file diff --git a/Engineer/prod/current_task_summary.sql b/Engineer/prod/current_task_summary.sql new file mode 100644 index 0000000..38a79ab --- /dev/null +++ b/Engineer/prod/current_task_summary.sql @@ -0,0 +1,11 @@ +select distinct + full_task_history.task_id, + full_task_history.task_title, + full_task_history.task_type, + full_task_history.task_due_date, + full_task_history.project_id, + full_task_history.task_status, + full_task_history.first_in_progress_date, + full_task_history.last_completed_date +from {{ ref('full_task_history') }} full_task_history +where full_task_history.history_sequence = 1 \ No newline at end of file