Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix/start-of-week patch #68

Merged
merged 4 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# dbt_zendesk v0.8.2
## Fixes
- It was brought to our attention that the `dbt_utils.date_trunc` macro only leverages the default arguments of the date_trunc function in the various warehouses. For example, `date_trunc` in Snowflake for the `week` argument produces the starting Monday, while BigQuery produces the starting Sunday. For this package, we want to leverage the start of the week as Sunday. Therefore, logic within the business metric intermediate models has been adjusted to capture the start of the week as Sunday. This was done by leveraging the `week_start` macro within the `dbt-date` package. ([#68](https://github.com/fivetran/dbt_zendesk/pull/68))
# dbt_zendesk v0.8.1
## Fixes
- The `0.7.1` release of the zendesk package introduced a bug within the `zendesk__sla_policy` model that caused duplicate sla records via a [join condition](https://github.com/fivetran/dbt_zendesk/blob/v0.7.1/models/sla_policy/int_zendesk__sla_policy_applied.sql#L48). This join condition has been modified to leverage the more accurate `sla_policy_applied.valid_starting_at` field instead of the `sla_policy_applied.sla_applied_at` which changes for `first_reply_time` slas. ([#67](https://github.com/fivetran/dbt_zendesk/pull/67))
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'zendesk'
version: '0.8.1'
version: '0.8.2'

config-version: 2
require-dbt-version: [">=1.0.0", "<2.0.0"]
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config-version: 2

name: 'zendesk_integration_tests'
version: '0.8.1'
version: '0.8.2'

profile: 'integration_tests'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ with ticket_historical_status as (

select
ticket_status_crossed_with_schedule.*,
({{ fivetran_utils.timestamp_diff(
"" ~ dbt_utils.date_trunc('week', 'ticket_status_crossed_with_schedule.status_schedule_start') ~ "",
'ticket_status_crossed_with_schedule.status_schedule_start',
'second') }} /60
) as start_time_in_minutes_from_week,
({{ fivetran_utils.timestamp_diff(
"cast(" ~ dbt_date.week_start('ticket_status_crossed_with_schedule.status_schedule_start','UTC') ~ "as " ~ dbt_utils.type_timestamp() ~ ")",
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
"cast(ticket_status_crossed_with_schedule.status_schedule_start as " ~ dbt_utils.type_timestamp() ~ ")",
'second') }} /60
) as start_time_in_minutes_from_week,
({{ fivetran_utils.timestamp_diff(
'ticket_status_crossed_with_schedule.status_schedule_start',
'ticket_status_crossed_with_schedule.status_schedule_end',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ with ticket_reply_times as (

), ticket_schedules as (

select *
select
*
from {{ ref('int_zendesk__ticket_schedules') }}

), schedule as (
Expand Down Expand Up @@ -37,8 +38,8 @@ with ticket_reply_times as (
min(first_reply_time.agent_responded_at) as agent_responded_at,

({{ fivetran_utils.timestamp_diff(
"" ~ dbt_utils.date_trunc('week', 'ticket_schedules.schedule_created_at') ~ "",
'ticket_schedules.schedule_created_at',
"cast(" ~ dbt_date.week_start('ticket_schedules.schedule_created_at','UTC') ~ "as " ~ dbt_utils.type_timestamp() ~ ")",
"cast(ticket_schedules.schedule_created_at as " ~ dbt_utils.type_timestamp() ~ ")",
'second') }} /60
) as start_time_in_minutes_from_week,
greatest(0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ with ticket_resolution_times_calendar as (

-- bringing this in the determine which schedule (Daylight Savings vs Standard time) to use
min(ticket_resolution_times_calendar.first_solved_at) as first_solved_at,

({{ fivetran_utils.timestamp_diff(
"" ~ dbt_utils.date_trunc('week', 'ticket_schedules.schedule_created_at') ~ "",
'ticket_schedules.schedule_created_at',
"cast(" ~ dbt_date.week_start('ticket_schedules.schedule_created_at','UTC') ~ "as " ~ dbt_utils.type_timestamp() ~ ")",
"cast(ticket_schedules.schedule_created_at as " ~ dbt_utils.type_timestamp() ~ ")",
'second') }} /60
) as start_time_in_minutes_from_week,
greatest(0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ with ticket_resolution_times_calendar as (

-- bringing this in the determine which schedule (Daylight Savings vs Standard time) to use
min(ticket_resolution_times_calendar.last_solved_at) as last_solved_at,

({{ fivetran_utils.timestamp_diff(
"" ~ dbt_utils.date_trunc('week', 'ticket_schedules.schedule_created_at') ~ "",
'ticket_schedules.schedule_created_at',
"cast(" ~ dbt_date.week_start('ticket_schedules.schedule_created_at','UTC') ~ "as " ~ dbt_utils.type_timestamp() ~ ")",
"cast(ticket_schedules.schedule_created_at as " ~ dbt_utils.type_timestamp() ~ ")",
'second') }} /60
) as start_time_in_minutes_from_week,
greatest(0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ with agent_work_time_filtered_statuses as (

select
ticket_status_crossed_with_schedule.*,
({{ fivetran_utils.timestamp_diff(
"" ~ dbt_utils.date_trunc(
'week',
'ticket_status_crossed_with_schedule.valid_starting_at') ~ "",
'ticket_status_crossed_with_schedule.valid_starting_at',
'second') }} /60
) as valid_starting_at_in_minutes_from_week,
({{ fivetran_utils.timestamp_diff(
"cast(" ~ dbt_date.week_start('ticket_status_crossed_with_schedule.valid_starting_at','UTC') ~ "as " ~ dbt_utils.type_timestamp() ~ ")",
"cast(ticket_status_crossed_with_schedule.valid_starting_at as " ~ dbt_utils.type_timestamp() ~ ")",
'second') }} /60
) as valid_starting_at_in_minutes_from_week,
({{ fivetran_utils.timestamp_diff(
'ticket_status_crossed_with_schedule.valid_starting_at',
'ticket_status_crossed_with_schedule.valid_ending_at',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ with ticket_schedules as (
select
sla_policy_applied.*,
ticket_schedules.schedule_id,
(
{{ fivetran_utils.timestamp_diff(
"" ~ dbt_utils.date_trunc('week', 'sla_policy_applied.sla_applied_at') ~ "",
'sla_policy_applied.sla_applied_at',
'second') }} /60
) as start_time_in_minutes_from_week,
({{ fivetran_utils.timestamp_diff(
"cast(" ~ dbt_date.week_start('sla_policy_applied.sla_applied_at','UTC') ~ "as " ~ dbt_utils.type_timestamp() ~ ")",
"cast(sla_policy_applied.sla_applied_at as " ~ dbt_utils.type_timestamp() ~ ")",
'second') }} /60
) as start_time_in_minutes_from_week,
schedule_business_hours.total_schedule_weekly_business_minutes
from sla_policy_applied
left join ticket_schedules on sla_policy_applied.ticket_id = ticket_schedules.ticket_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ with requester_wait_time_filtered_statuses as (
select
ticket_status_crossed_with_schedule.*,
({{ fivetran_utils.timestamp_diff(
"" ~ dbt_utils.date_trunc(
'week',
'ticket_status_crossed_with_schedule.valid_starting_at') ~ "",
'ticket_status_crossed_with_schedule.valid_starting_at',
'second') }} /60
) as valid_starting_at_in_minutes_from_week,
"cast(" ~ dbt_date.week_start('ticket_status_crossed_with_schedule.valid_starting_at','UTC') ~ "as " ~ dbt_utils.type_timestamp() ~ ")",
"cast(ticket_status_crossed_with_schedule.valid_starting_at as " ~ dbt_utils.type_timestamp() ~ ")",
'second') }} /60
) as valid_starting_at_in_minutes_from_week,
({{ fivetran_utils.timestamp_diff(
'ticket_status_crossed_with_schedule.valid_starting_at',
'ticket_status_crossed_with_schedule.valid_ending_at',
Expand Down
4 changes: 3 additions & 1 deletion packages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packages:
- package: fivetran/zendesk_source
version: [">=0.6.0","<0.7.0"]
version: [">=0.6.0","<0.7.0"]
- package: calogica/dbt_date
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
version: [">=0.5.0", "<0.6.0"]