Skip to content

Commit

Permalink
Added valid authors test + ran pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonvermeulen committed Nov 10, 2023
1 parent d10a96b commit e64df8c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Pull request checks
on:
pull_request:
paths-ignore:
- 'webapp/**'
- "webapp/**"
env:
DUCKDB_PATH: github_contributions.duckdb

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/webapp_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Web-app CI
on:
pull_request:
paths:
- 'webapp/**'
- "webapp/**"
env:
WORKING_DIRECTORY: ./webapp

Expand Down
28 changes: 14 additions & 14 deletions models/marts/fct_pull_requests.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
with authors as (
select *
FROM (VALUES
{%- for author in var("authors") -%}
('{{ author.name }}', '{{ author.organization }}')
{%- if not loop.last %}, {%- endif -%}
{%- endfor -%}
) Author(name, organization)
)
with
authors as (
select *
from
(
values
{%- for author in var("authors") -%}
('{{ author.name }}', '{{ author.organization }}')
{%- if not loop.last %}, {%- endif -%}
{%- endfor -%}
) author(name, organization)
)

select
pull_requests.title,
Expand All @@ -26,8 +29,5 @@ select
pull_requests.pull_request_merged_at as merged_at,
pull_requests.reactions_total_count,
pull_requests.html_url as url,
from
{{ ref("int_pull_requests") }} AS pull_requests
left join
authors
ON pull_requests.user_login = authors.name
from {{ ref("int_pull_requests") }} as pull_requests
left join authors on pull_requests.user_login = authors.name
7 changes: 3 additions & 4 deletions models/staging/stg_github_contributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ models:
- not_null
- unique
- name: user_login
# TODO(anyone) temporarily disabled test because it keeps failing, debug and revert this later
# tests:
# - accepted_values:
# values: "{{ var('author_string').split(',') }}"
tests:
- only_valid_authors:
valid_authors: "{{ var('author_string').split(',') }}"

- name: stg_repositories
tests:
Expand Down
23 changes: 23 additions & 0 deletions tests/generic/test_only_valid_authors.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% test only_valid_authors(model, column_name, valid_authors) %}

with validation as (
select
distinct lower({{ column_name }}) as author
from {{ model }}
),

validation_errors as (
select
author
from validation
where author not in (
{%- for author in valid_authors -%}
'{{ author | lower }}'{% if not loop.last %},{% endif %}
{%- endfor -%}
)
)

select *
from validation_errors

{% endtest %}

0 comments on commit e64df8c

Please sign in to comment.