Merged PR 4530: first comment time added

# Description

First comment time added

# Checklist

- [x] The edited models and dependants run properly with production data.
- [x] The edited models are sufficiently documented.
- [x] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

first comment time added

Related work items: #27812
This commit is contained in:
Joaquin Ossa 2025-02-27 12:28:09 +00:00 committed by Oriol Roqué Paniagua
parent 47fde7de60
commit 42701b4d2c
5 changed files with 29 additions and 0 deletions

View file

@ -159,6 +159,14 @@ select
lt.first_comment_at_utc, lt.first_comment_at_utc,
lt.last_comment_at_utc, lt.last_comment_at_utc,
lt.comment_count, lt.comment_count,
case
when lt.first_comment_at_utc is not null
then
(
extract(epoch from (lt.first_comment_at_utc - i.created_at_utc)) / 3600
)::decimal(19, 4)
else null
end as time_to_first_comment_in_hours,
lt.first_status_at_utc, lt.first_status_at_utc,
lt.last_status_at_utc, lt.last_status_at_utc,
case case

View file

@ -71,6 +71,14 @@ models:
data_type: bigint data_type: bigint
description: "Number of comments submitted on the incident." description: "Number of comments submitted on the incident."
- name: time_to_first_comment_in_hours
data_type: numeric
description: "Time taken to reach the client for the first time."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: true
- name: first_status_at_utc - name: first_status_at_utc
data_type: timestamp data_type: timestamp
description: "Timestamp of the first status change on the incident." description: "Timestamp of the first status change on the incident."

View file

@ -17,6 +17,7 @@ select
first_comment_at_utc as first_comment_at_utc, first_comment_at_utc as first_comment_at_utc,
last_comment_at_utc as last_comment_at_utc, last_comment_at_utc as last_comment_at_utc,
comment_count as comment_count, comment_count as comment_count,
time_to_first_comment_in_hours as time_to_first_comment_in_hours,
first_status_at_utc as first_status_at_utc, first_status_at_utc as first_status_at_utc,
last_status_at_utc as last_status_at_utc, last_status_at_utc as last_status_at_utc,
resolution_time_in_hours as resolution_time_in_hours, resolution_time_in_hours as resolution_time_in_hours,

View file

@ -71,6 +71,14 @@ models:
data_type: bigint data_type: bigint
description: "Number of comments submitted on the incident." description: "Number of comments submitted on the incident."
- name: time_to_first_comment_in_hours
data_type: numeric
description: "Time taken to reach the client for the first time."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: true
- name: first_status_at_utc - name: first_status_at_utc
data_type: timestamp data_type: timestamp
description: "Timestamp of the first status change on the incident." description: "Timestamp of the first status change on the incident."

View file

@ -3,6 +3,8 @@
-- Many of them don't have the same necessary fields as the current model. -- Many of them don't have the same necessary fields as the current model.
-- The same happens with the 'ManualFormWeb' document_version. -- The same happens with the 'ManualFormWeb' document_version.
{% set old_or_manual_documents = ("OLDCLAIMTOINCIDENTMODEL", "MANUALFORMWEB") %} {% set old_or_manual_documents = ("OLDCLAIMTOINCIDENTMODEL", "MANUALFORMWEB") %}
-- Test or cancelled incidents are not considered in the reporting.
{% set tests_or_cancelled_incidents = "ARCHIVED" %}
with with
raw_incident as (select * from {{ source("resolutions", "incident") }}), raw_incident as (select * from {{ source("resolutions", "incident") }}),
@ -267,3 +269,5 @@ from deduped_verifications
where where
upper({{ adapter.quote("documents") }} ->> 'DocumentVersion') upper({{ adapter.quote("documents") }} ->> 'DocumentVersion')
not in {{ old_or_manual_documents }} not in {{ old_or_manual_documents }}
and upper({{ adapter.quote("documents") }} ->> 'CurrentStatusName')
<> '{{ tests_or_cancelled_incidents }}'