I wonder if we can create a channel like: #migrate...
# community-support
n
I wonder if we can create a channel like: #migrate-from-open-source ? Why? To be able to ask questions like this. How do I capture test coverage in
app.elementary
, with dbt evaluator package? • for a custom report that shows history of improvements. • with an incremental model. see code below:
Copy code
{{ config(
  materialized = 'incremental',
  on_schema_change = 'append_new_columns',
  unique_key = 'daily_measured_at__key'
) }}


WITH meet_condition AS (
  SELECT
    {{ dbt_utils.generate_surrogate_key([
    'measured_at'
  ]) }} AS daily_measured_at__key,
    DATE(measured_at) AS measured_at,
    total_models,
    total_tests,
    tested_models,
    test_coverage_pct,
    staging_test_coverage_pct,
    intermediate_test_coverage_pct,
    other_test_coverage_pct
    AS marts_test_coverage_pct,
    test_to_model_ratio,
    {{ dbt.current_timestamp() }} AS dbt_materialized_at
  FROM
    {{ ref('dbt_project_evaluator', 'fct_test_coverage') }}
),

validation_errors AS (
  SELECT *
  FROM meet_condition
  WHERE
    -- never true, defaults to an empty result set. Exists to ensure any combo of the `or` clauses below succeeds
    1 = 2
    -- records with a value >= min_value are permitted. The `not` flips this to find records that don't meet the rule.
    OR NOT test_coverage_pct >= 100
)

SELECT *
FROM validation_errors


{% if is_incremental() %}
  -- this filter will only be applied on an incremental run
  WHERE
    current_date() > 
    (SELECT MAX(date(measured_at))
      FROM
        {{ this }})
{% endif %}