Skip to content

Commit

Permalink
Add provisional assessment stages to PIN value views (#641)
Browse files Browse the repository at this point in the history
* Add pre-mailed and pre-certified stages to vw_pin_value

* Filter out orphaned records from default.vw_pin_value

* Update reporting.vw_pin_value_long to pull from default.vw_pin_value

* Use legacy stage name for "board certified" in reporting.vw_pin_value_long

* Add tests and docs for new vw_pin_value assessment stages

* Fix sorting in dbt yaml files

* Clean up docs for provisional assessment values

* Add comment to pre_stage_filters macro explaining `cur = 'Y'`

* Change pre-mailed assessment stage_num from 0 to 0.5

* Add comments to `clean_values` and `change_reasons` CTEs in default.vw_pin_value

* Add docs and column definitions for provisional values in default.vw_pin_value

* Fix column sort order in default.vw_pin_value
  • Loading branch information
jeancochrane authored Nov 18, 2024
1 parent ba9db30 commit 6a2a3f9
Show file tree
Hide file tree
Showing 9 changed files with 753 additions and 135 deletions.
21 changes: 21 additions & 0 deletions dbt/macros/pre_stage_filters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Macros to simplify the filter conditions that produce pre-mailed and
-- pre-certified values.
--
-- Note that the `cur = 'Y'` filter is not necessary in the
-- default.vw_pin_value query that is the main consumer of these macros, since
-- that query already filters rows where `cur = 'Y'`; however, we leave the
-- filter in here so that it might make the macro more generally useful in
-- other instances where we may not filter queries the same way
{% macro pre_stage_filters(tablename, stage_name) %}
{{ tablename }}.procname is null
and {{ tablename }}.cur = 'Y'
and not contains(stages.procnames, '{{ stage_name }}')
{% endmacro %}

{% macro pre_mailed_filters(tablename) %}
{{- pre_stage_filters(tablename, "CCAOVALUE") -}}
{% endmacro %}

{% macro pre_certified_filters(tablename) %}
{{- pre_stage_filters(tablename, "CCAOFINAL") -}}
{% endmacro %}
1 change: 1 addition & 0 deletions dbt/macros/tests/test_all.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
{% do test_generate_schema_name() %}
{% do test_generate_alias_name() %}
{% do test_format_additional_select_columns() %}
{% do test_pre_stage_filters() %}
{% endmacro %}
47 changes: 47 additions & 0 deletions dbt/macros/tests/test_pre_stage_filters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% macro test_pre_stage_filters() %}
{% do test_pre_stage_filters_params() %}
{% do test_pre_mailed_filters() %}
{% do test_pre_certified_filters() %}
{% endmacro %}

{% macro expected_pre_mailed_filters() %}
asmt.procname is null
and asmt.cur = 'Y'
and not contains(stages.procnames, 'CCAOVALUE')
{% endmacro %}

{% macro expected_pre_certified_filters() %}
asmt.procname is null
and asmt.cur = 'Y'
and not contains(stages.procnames, 'CCAOFINAL')
{% endmacro %}

{% macro test_pre_stage_filters_params() %}
{{
assert_equals(
"test_pre_stage_filters_params",
pre_stage_filters("asmt", "CCAOVALUE"),
expected_pre_mailed_filters(),
)
}}
{% endmacro %}

{% macro test_pre_mailed_filters() %}
{{
assert_equals(
"test_pre_mailed_filters_params",
pre_mailed_filters("asmt"),
expected_pre_mailed_filters(),
)
}}
{% endmacro %}

{% macro test_pre_certified_filters() %}
{{
assert_equals(
"test_pre_certified_filters_params",
pre_certified_filters("asmt"),
expected_pre_certified_filters(),
)
}}
{% endmacro %}
Loading

0 comments on commit 6a2a3f9

Please sign in to comment.