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

Achievement/specialist #119

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ clovek_debata.csv
data/*.db
data/*.csv
data/*.sql
data/adk_wrapped.db.wal
data/*.wal

# MacOS
.DS_Store
22 changes: 21 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
{
"python.formatting.provider": "black"
"terminal.integrated.env.osx": {
// Environment variables for a dbt run outside of Docker/Meltano
// If you change them here, make sure to change them in terminal.integrated.env.linux/windows
"DBT_PROJECT_DIR": "${workspaceFolder}/greybox_conversion/transform",
"DBT_PROFILES_DIR": "${workspaceFolder}/greybox_conversion/transform/profiles/duckdb",
"DBT_DUCKDB_PATH": "${workspaceFolder}/data/adk_wrapped_full.db",
"MELTANO_PROJECT_ROOT": "${workspaceFolder}/greybox_conversion",
"TARGET_DUCKDB_FINAL_FILENAME": "adk_wrapped",
"TARGET_DUCKDB_INTERMEDIATE_FILENAME": "adk_wrapped_full",
"VSCODE_WORKSPACE": "${workspaceFolder}",
},
"terminal.integrated.env.windows": {
// Exact same as above
"DBT_PROJECT_DIR": "${workspaceFolder}/greybox_conversion/transform",
"DBT_PROFILES_DIR": "${workspaceFolder}/greybox_conversion/transform/profiles/duckdb",
"DBT_DUCKDB_PATH": "${workspaceFolder}/data/adk_wrapped_full.db",
"MELTANO_PROJECT_ROOT": "${workspaceFolder}/greybox_conversion",
"TARGET_DUCKDB_FINAL_FILENAME": "adk_wrapped",
"TARGET_DUCKDB_INTERMEDIATE_FILENAME": "adk_wrapped_full",
"VSCODE_WORKSPACE": "${workspaceFolder}",
},
}
2 changes: 1 addition & 1 deletion greybox_conversion/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# registry.gitlab.com/meltano/meltano:latest is also available in GitLab Registry
ARG MELTANO_IMAGE=meltano/meltano:latest
ARG MELTANO_IMAGE=meltano/meltano:v3.4.0
FROM $MELTANO_IMAGE

WORKDIR /project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ models:
columns: *STANDARD_ACHIEVEMENT_COLUMNS
- name: agg__vazena_pomoc
columns: *STANDARD_ACHIEVEMENT_COLUMNS
- name: agg__specialist
description: >
Debatér dostal více bodů mimo standardní debatní akce než na nich.
columns: *STANDARD_ACHIEVEMENT_COLUMNS
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
with ib_points as (
select * from {{ ref('base__debater_ib') }}
),

grouped_points as (
select
clovek_id,
school_year,
activity_type,
sum(ibody)::float as total_ib_points
from ib_points
group by 1, 2, 3
),

pivoted_points as (
select
clovek_id,
school_year,
max(case when activity_type = 'debate' then total_ib_points end) as debate_ib_points,
max(case when activity_type = 'other' then total_ib_points end) as other_ib_points,
other_ib_points / debate_ib_points as points_ratio
from grouped_points
group by 1, 2
having
debate_ib_points > 5
and other_ib_points > 5
),

achievement as (
select
clovek_id,
school_year,
{{ make_achievement_id('specialist') }},
'Specialist(k)a' as achievement_name,
'Kolik nedebatní IB aktivity zvládneš? Alespoň ' || round(points_ratio, 1) || 'x více než debatní!' as achievement_description,
3 as achievement_priority,
json_object(
'debate_ib_points', round(debate_ib_points, 3),
'other_ib_points', round(other_ib_points, 3),
'points_ratio', round(points_ratio, 2)
) as achievement_data,
'binary' as achievement_type
from pivoted_points
where points_ratio > 1.2
)

select * from achievement
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ with all_achievements_unioned as (
ref("agg__first_judge"),
ref("agg__judge_debates"),
ref("agg__vazena_pomoc"),
ref("agg__specialist"),
],
)
}}
Expand Down
11 changes: 10 additions & 1 deletion greybox_conversion/transform/profiles/duckdb/profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ meltano:
path: "{{ env_var('DBT_DUCKDB_PATH') }}"
threads: 8
attach:
- path: "{{ env_var('MELTANO_PROJECT_ROOT') }}/output/{{ env_var('TARGET_DUCKDB_FINAL_FILENAME', 'adk_wrapped') }}.db"
# What's going on here: Either MELTANO_PROJECT_READONLY is set by the Dockerfile, in which case we'll use
# the output directory (which is itself mounted to data/ outside of Docker)...
# or it's not, in which case we'll use the data directory.
#
# The relevant variables are defined either in docker-compose.data_prep.yml or in .vscode/settings.json.
- path: "{% if env_var('MELTANO_PROJECT_READONLY', 0) == 1 %}\
{{ env_var('MELTANO_PROJECT_ROOT') }}/output/{{ env_var('TARGET_DUCKDB_FINAL_FILENAME', 'adk_wrapped') }}.db\
{% else %}\
{{ env_var('VSCODE_WORKSPACE', '.') }}/data/{{ env_var('TARGET_DUCKDB_FINAL_FILENAME', 'adk_wrapped') }}.db\
{% endif %}"
alias: final
staging:
<<: *dev
Expand Down