Skip to content

Commit

Permalink
OK-602 urheilijatutkinto kiinnostaa
Browse files Browse the repository at this point in the history
  • Loading branch information
Matz Rasmus committed Feb 11, 2025
1 parent 4d6d815 commit f31abd4
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 38 deletions.
4 changes: 3 additions & 1 deletion dbt/models/int/int_ataru/int_ataru_hakemus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ final as (
when tila = 'inactivated'
then cast(true as boolean)
else cast(false as boolean)
end as poistettu
end as poistettu,
(tiedot ->> '1dc3311d-2235-40d6-88d2-de2bd63e087b')::boolean as urheilijatutkinto_kiinnostaa

from raw
where
row_nr = 1
Expand Down
11 changes: 9 additions & 2 deletions dbt/models/int/int_hakutoive.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ valinnat as (
select * from {{ ref('int_valinta') }}
),

harkinnanvaraisuus as (
select * from {{ ref('int_sure_harkinnanvaraisuus') }}
),

int as (
select
hato.hakutoive_id,
Expand All @@ -49,13 +53,15 @@ int as (
)
as viimeinen_vastaanottopaiva,
vaot.vastaanottotieto,
vali.valintatapajonot
vali.valintatapajonot,
hava.harkinnanvaraisuuden_syy
from hakutoive as hato
left join julkaistu as julk on hato.hakukohde_henkilo_id = julk.hakukohde_henkilo_id
left join hakemus as hake on hato.hakemus_oid = hake.hakemus_oid
left join haku on hake.haku_oid = haku.haku_oid
left join vastaanotto as vaot on hato.hakukohde_henkilo_id = vaot.hakukohde_henkilo_id
left join valinnat as vali on hato.hakutoive_id = vali.hakutoive_id
left join harkinnanvaraisuus as hava on hato.hakutoive_id = hava.hakutoive_id
),

final as (
Expand All @@ -78,7 +84,8 @@ final as (
case when vastaanotto_paattyy::time - viimeinen_vastaanottopaiva::time < '0:00:00'::time then 1 else 0 end
) as viimeinen_vastaanottopaiva,
vastaanottotieto,
valintatapajonot
valintatapajonot,
harkinnanvaraisuuden_syy
from int
)

Expand Down
31 changes: 0 additions & 31 deletions dbt/models/int/int_urheilijatutkinto.sql

This file was deleted.

32 changes: 32 additions & 0 deletions dbt/models/int/int_urheilijatutkinto_hakukohde.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
with raw as (
select
content,
row_number() over (partition by id order by versio_id desc, muokattu desc) as rownr
from {{ ref('dw_ataru_lomake') }}
WHERE
content @> '[{"id": "1dc3311d-2235-40d6-88d2-de2bd63e087b"}]' or
content @> '[{"id": "ammatillinen_perustutkinto_urheilijana"}]'

),

hakukohderyhma_hakukohde as (
select * from {{ ref('int_hakukohderyhma_hakukohde') }}
),

content as (
select
jsonb_array_elements(content) as content
from raw where rownr = 1
),

hakukohderyhmat as (
select
jsonb_array_elements_text(a.content -> 'belongs-to-hakukohderyhma') as hakukohderyhma_oid
from content a
where content ->> 'id' in ('1dc3311d-2235-40d6-88d2-de2bd63e087b','ammatillinen_perustutkinto_urheilijana')
)

select distinct
haha.hakukohde_oid
from hakukohderyhma_hakukohde as haha
join hakukohderyhmat as hary on haha.hakukohderyhma_oid =hary.hakukohderyhma_oid
3 changes: 2 additions & 1 deletion dbt/models/int/int_yleiskayttoiset/int_onr_henkilo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
incremental_strategy = 'merge',
indexes = [
{'columns': ['henkilo_oid','master_oid']},
{'columns':['henkilo_oid','kansalaisuus']}
{'columns':['henkilo_oid','kansalaisuus']},
{'columns':['muokattu']}
]
)
}}
Expand Down
6 changes: 6 additions & 0 deletions dbt/models/pub/_pub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ models:
- name: valintatapajonot
data_type: jsonb
description: Hakutoiveen kaikkien valintatapajonojen tiedot json-muotoisena
- name: harkinnanvaraisuuden_syy
data_type: text
- name: pub_dim_hakukohde
description: Tämä taulu sisältää aktiiviset hakukohteet ja niiden tietoja.
config:
Expand Down Expand Up @@ -99,6 +101,10 @@ models:
data_type: boolean
- name: jarjestaa_urheilijan_ammkoulutusta
data_type: boolean
- name: oppilaitoksen_opetuskieli
data_type: jsonb
- name: koulutus_oid
data_type: text
- name: pub_dim_haku
description: Hakujen tietoja
config:
Expand Down
6 changes: 5 additions & 1 deletion dbt/models/pub/pub_dim_hakukohde.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ int as (
hako.tila,
hako.haku_oid,
hako.toteutus_oid,
koul.koulutus_oid,
hako.jarjestyspaikka_oid,
hako.aloituspaikat,
hako.aloituspaikat_ensikertalaisille,
Expand All @@ -61,7 +62,8 @@ int as (
hako.koulutuksenalkamiskausi, (coalesce(haku.koulutuksen_alkamiskausi, tote.koulutuksen_alkamiskausi))
) as koulutuksen_alkamiskausi,
hako.toinenasteonkokaksoistutkinto as toinen_aste_onko_kaksoistutkinto,
coalesce(hako.jarjestaaurheilijanammkoulutusta, false) as jarjestaa_urheilijan_ammkoulutusta
coalesce(hako.jarjestaaurheilijanammkoulutusta, false) as jarjestaa_urheilijan_ammkoulutusta,
tote.oppilaitoksen_opetuskieli
from hakukohde as hako
left join toteutus as tote on hako.toteutus_oid = tote.toteutus_oid
left join haku as haku on hako.haku_oid = haku.haku_oid
Expand All @@ -88,7 +90,9 @@ final as (
tila,
haku_oid,
toteutus_oid,
koulutus_oid,
jarjestyspaikka_oid,
oppilaitoksen_opetuskieli,
aloituspaikat,
aloituspaikat_ensikertalaisille,
hakukohdekoodiuri,
Expand Down
3 changes: 2 additions & 1 deletion dbt/models/pub/pub_dim_hakutoive.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ final as (
hakutoivenumero,
viimeinen_vastaanottopaiva,
vastaanottotieto,
valintatapajonot
valintatapajonot,
harkinnanvaraisuuden_syy
from hakutoive
)

Expand Down
12 changes: 11 additions & 1 deletion dbt/models/pub/pub_dim_hakutoive_toinen_aste.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ kaksoistutkinto as (
select * from {{ ref('int_kaksoistutkinto') }}
),

urheilijatutkinto as (
select * from {{ ref('int_urheilijatutkinto_hakukohde') }}
),

ilmoittautuminen as (
select
hakukohde_henkilo_id,
Expand All @@ -48,12 +52,18 @@ final as (
coalesce(sora.sora_aiempi, '0') = '1' as sora_aiempi,
hava.harkinnanvaraisuuden_syy,
ilmo.tila,
coalesce(katu.kaksoistutkinto_kiinnostaa, false::boolean) as kaksoistutkinto_kiinnostaa
coalesce(katu.kaksoistutkinto_kiinnostaa, false::boolean) as kaksoistutkinto_kiinnostaa,
case
when urtu.hakukohde_oid is not null
then true::boolean
else false::boolean
end as urheilijatutkinto_kiinnostaa
from hakutoive as hato
left join sora on hato.hakutoive_id = sora.hakutoive_id
left join harkinnanvaraisuus as hava on hato.hakutoive_id = hava.hakutoive_id
left join ilmoittautuminen as ilmo on hato.hakukohde_henkilo_id = ilmo.hakukohde_henkilo_id
left join kaksoistutkinto as katu on hato.hakutoive_id = katu.hakutoive_id
left join urheilijatutkinto as urtu on hato.hakukohde_oid = urtu.hakukohde_oid
)

select final.*
Expand Down

0 comments on commit f31abd4

Please # to comment.