Skip to content

Commit

Permalink
fix and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-reneeli committed Jan 17, 2024
1 parent 4be7221 commit 8d45984
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 21 deletions.
9 changes: 9 additions & 0 deletions models/servicenow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,15 @@ models:

- name: servicenow__activity_summary
description: '{{ doc("servicenow__activity_summary") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- task_updated_date
- task_state
- priority
- impact
- urgency
- source_relation
columns:
- name: task_updated_date
description: '{{ doc("task_updated_date") }}'
Expand Down
3 changes: 2 additions & 1 deletion models/servicenow__activity_summary.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ select
sum(total_incidents_caused_by_problem) as total_incidents_caused_by_problems,
count(distinct associated_change_request_id) as total_change_requests,
count(distinct case when task_closed_at is not null then task_id end) as total_closed_tasks,
avg(task_minutes_to_close) as average_minutes_to_close -- just added this.. need to debug
avg(task_minutes_to_close) as average_minutes_to_close,
count(case when is_made_sla then 1 end) as total_tasks_made_slas

from ticket_enhanced
group by 1,2,3,4,5,6
94 changes: 75 additions & 19 deletions models/staging/stg_servicenow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ version: 2
models:
- name: stg_servicenow__task
description: '{{ doc("stg_servicenow__task") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- task_id
- source_relation
columns:
- name: task_id
description: '{{ doc("sys_id") }}'
tests:
- unique
- not_null

- name: source_relation
Expand Down Expand Up @@ -270,11 +274,15 @@ models:

- name: stg_servicenow__task_sla
description: '{{ doc("stg_servicenow__task_sla") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- task_sla_id
- source_relation
columns:
- name: task_sla_id
description: '{{ doc("sys_id") }}'
tests:
- unique
- not_null

- name: source_relation
Expand Down Expand Up @@ -372,11 +380,15 @@ models:

- name: stg_servicenow__sys_user
description: '{{ doc("stg_servicenow__sys_user") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- user_id
- source_relation
columns:
- name: user_id
description: '{{ doc("sys_id") }}'
tests:
- unique
- not_null

- name: source_relation
Expand Down Expand Up @@ -600,11 +612,15 @@ models:

- name: stg_servicenow__problem
description: '{{ doc("stg_servicenow__problem") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- problem_id
- source_relation
columns:
- name: problem_id
description: '{{ doc("sys_id") }}'
tests:
- unique
- not_null

- name: source_relation
Expand Down Expand Up @@ -735,11 +751,15 @@ models:

- name: stg_servicenow__problem_task
description: '{{ doc("stg_servicenow__problem_task") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- problem_task_id
- source_relation
columns:
- name: problem_task_id
description: '{{ doc("sys_id") }}'
tests:
- unique
- not_null

- name: source_relation
Expand Down Expand Up @@ -804,11 +824,15 @@ models:

- name: stg_servicenow__incident
description: '{{ doc("stg_servicenow__incident") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- incident_id
- source_relation
columns:
- name: incident_id
description: '{{ doc("sys_id") }}'
tests:
- unique
- not_null

- name: source_relation
Expand Down Expand Up @@ -921,11 +945,15 @@ models:

- name: stg_servicenow__change_task
description: '{{ doc("stg_servicenow__change_task") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- change_task_id
- source_relation
columns:
- name: change_task_id
description: '{{ doc("sys_id") }}'
tests:
- unique
- not_null

- name: source_relation
Expand Down Expand Up @@ -972,11 +1000,15 @@ models:

- name: stg_servicenow__change_request
description: '{{ doc("stg_servicenow__change_request") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- change_request_id
- source_relation
columns:
- name: change_request_id
description: '{{ doc("sys_id") }}'
tests:
- unique
- not_null

- name: _fivetran_deleted
Expand Down Expand Up @@ -1117,13 +1149,16 @@ models:

- name: stg_servicenow__core_company
description: '{{ doc("stg_servicenow__core_company") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- problem_task_id
- source_relation
columns:
- name: problem_task_id
description: '{{ doc("sys_id") }}'
tests:
- unique
- not_null

- name: source_relation
description: '{{ doc("source_relation") }}'
- name: core_company_id
Expand Down Expand Up @@ -1172,7 +1207,16 @@ models:

- name: stg_servicenow__cmdb_ci
description: '{{ doc("stg_servicenow__cmdb_ci") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- cmdb_ci_id
- source_relation
columns:
- name: cmdb_ci_id
description: '{{ doc("sys_id") }}'
tests:
- not_null
- name: _fivetran_deleted
description: '{{ doc("_fivetran_deleted") }}'
- name: _fivetran_synced
Expand Down Expand Up @@ -1233,8 +1277,6 @@ models:
description: '{{ doc("sys_domain_path") }}'
- name: sys_domain_value
description: '{{ doc("sys_domain_value") }}'
- name: cmdb_ci_id
description: '{{ doc("sys_id") }}'
- name: sys_mod_count
description: '{{ doc("sys_mod_count") }}'
- name: sys_updated_by
Expand All @@ -1248,7 +1290,16 @@ models:

- name: stg_servicenow__cmdb_ci_service
description: '{{ doc("stg_servicenow__cmdb_ci_service") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- cmdb_ci_service_id
- source_relation
columns:
- name: cmdb_ci_service_id
description: '{{ doc("sys_id") }}'
tests:
- not_null
- name: _fivetran_deleted
description: '{{ doc("_fivetran_deleted") }}'
- name: _fivetran_synced
Expand Down Expand Up @@ -1299,7 +1350,7 @@ models:
description: '{{ doc("sla_link") }}'
- name: sla_value
description: '{{ doc("sla_value") }}'
- name: state
- name: cmdb_ci_service_state
description: '{{ doc("state") }}'
- name: subcategory
description: '{{ doc("subcategory") }}'
Expand All @@ -1317,8 +1368,6 @@ models:
description: '{{ doc("sys_domain_path") }}'
- name: sys_domain_value
description: '{{ doc("sys_domain_value") }}'
- name: cmdb_ci_service_id
description: '{{ doc("sys_id") }}'
- name: sys_mod_count
description: '{{ doc("sys_mod_count") }}'
- name: sys_updated_by
Expand All @@ -1332,9 +1381,16 @@ models:

- name: stg_servicenow__sys_user_group
description: '{{ doc("stg_servicenow__sys_user_group") }}'
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- sys_user_group_id
- source_relation
columns:
- name: sys_id
- name: sys_user_group_id
description: '{{ doc("sys_id") }}'
tests:
- not_null

- name: _fivetran_deleted
description: '{{ doc("_fivetran_deleted") }}'
Expand Down Expand Up @@ -1393,7 +1449,7 @@ models:
- name: sys_created_by
description: '{{ doc("sys_created_by") }}'

- name: sys_created_on
- name: sys_user_group_created_at
description: '{{ doc("sys_created_on") }}'

- name: sys_mod_count
Expand All @@ -1402,10 +1458,10 @@ models:
- name: sys_updated_by
description: '{{ doc("sys_updated_by") }}'

- name: sys_updated_on
- name: sys_user_group_updated_at
description: '{{ doc("sys_updated_on") }}'

- name: type
- name: sys_user_group_type
description: '{{ doc("type") }}'


2 changes: 1 addition & 1 deletion models/staging/stg_servicenow__cmdb_ci_service.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final as (
short_description,
sla_link,
cast(sla_value as {{ dbt.type_string() }}) as sla_value,
state,
state as cmdb_ci_service_state,
subcategory,
sys_class_name,
sys_class_path,
Expand Down

0 comments on commit 8d45984

Please sign in to comment.