Skip to content
1 change: 1 addition & 0 deletions Engineer/prep/base/projects.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Engineer/prep/intermediate/full_project_history.sql
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
13 changes: 11 additions & 2 deletions Engineer/prod/current_project_summary.sql
Original file line number Diff line number Diff line change
@@ -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
, first_active_week
, full_project_history.first_paused_date
, first_paused_week
, full_project_history.last_completed_date
11 changes: 11 additions & 0 deletions Engineer/prod/current_task_summary.sql
Original file line number Diff line number Diff line change
@@ -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