Compare commits
2 Commits
48d0762c15
...
e72bb37106
| Author | SHA1 | Date | |
|---|---|---|---|
| e72bb37106 | |||
| 88b52d85e7 |
@@ -66,6 +66,15 @@ environments:
|
|||||||
skip_initial: 8
|
skip_initial: 8
|
||||||
sample_rate: 1
|
sample_rate: 1
|
||||||
max_sampling_read: 25000
|
max_sampling_read: 25000
|
||||||
|
- path: file://C:/Users/vdsje/OneDrive/LakeHouse/Sarens/Data/2025-06-11/
|
||||||
|
name: absenteisme
|
||||||
|
pattern: "Absenteisme.*"
|
||||||
|
start_date: '2000-01-01T00:00:00Z'
|
||||||
|
key_properties: []
|
||||||
|
format: excel
|
||||||
|
worksheet_name: Tabel
|
||||||
|
sample_rate: 1
|
||||||
|
max_sampling_read: 25000
|
||||||
select:
|
select:
|
||||||
- departments.*
|
- departments.*
|
||||||
- '!departments._*'
|
- '!departments._*'
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ select
|
|||||||
row_number() over (order by user_id, task_name)::bigint as id,
|
row_number() over (order by user_id, task_name)::bigint as id,
|
||||||
null::date as start,
|
null::date as start,
|
||||||
status,
|
status,
|
||||||
overall_rating,
|
nullif(regexp_replace(overall_rating, '\D','','g'), '')::numeric as overall_rating_value,
|
||||||
|
overall_rating as overall_rating_text,
|
||||||
cycle_id,
|
cycle_id,
|
||||||
worker_id,
|
worker_id,
|
||||||
null::bigint as reviewer_id,
|
null::bigint as reviewer_id,
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ total_scores as (
|
|||||||
select
|
select
|
||||||
r.review_id,
|
r.review_id,
|
||||||
t.section_name as dimension,
|
t.section_name as dimension,
|
||||||
nullif(trim(t.final_rating), '') as score,
|
nullif(regexp_replace(t.final_rating, '\D','','g'), '')::numeric as score_value,
|
||||||
|
nullif(trim(t.final_rating), '') as score_text,
|
||||||
null::text as comment
|
null::text as comment
|
||||||
from {{ source('tap_spreadsheets_anywhere', 'performance_review_total_scoring') }} t
|
from {{ source('tap_spreadsheets_anywhere', 'performance_review_total_scoring') }} t
|
||||||
join review_base r
|
join review_base r
|
||||||
@@ -28,7 +29,8 @@ sub_scores as (
|
|||||||
select
|
select
|
||||||
r.review_id,
|
r.review_id,
|
||||||
s.competency_name as dimension,
|
s.competency_name as dimension,
|
||||||
nullif(trim(s.competency_rating_score), '') as score,
|
nullif(regexp_replace(s.competency_rating_score, '\D','','g'), '')::numeric as score_value,
|
||||||
|
nullif(trim(s.competency_rating_score), '') as score_text,
|
||||||
null::text as comment
|
null::text as comment
|
||||||
from {{ source('tap_spreadsheets_anywhere', 'performance_review_sub_scoring') }} s
|
from {{ source('tap_spreadsheets_anywhere', 'performance_review_sub_scoring') }} s
|
||||||
join review_base r
|
join review_base r
|
||||||
@@ -39,7 +41,8 @@ sub_scores as (
|
|||||||
select
|
select
|
||||||
row_number() over (order by review_id, dimension)::bigint as id,
|
row_number() over (order by review_id, dimension)::bigint as id,
|
||||||
dimension,
|
dimension,
|
||||||
score, -- TODO: change to integer (score_value) + text (score_text)
|
score_value,
|
||||||
|
score_text,
|
||||||
comment,
|
comment,
|
||||||
review_id
|
review_id
|
||||||
from (
|
from (
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ sources:
|
|||||||
- name: workers
|
- name: workers
|
||||||
- name: performance_review_steps
|
- name: performance_review_steps
|
||||||
- name: performance_review_total_scoring
|
- name: performance_review_total_scoring
|
||||||
- name: performance_review_sub_scoring
|
- name: performance_review_sub_scoring
|
||||||
|
- name: absenteisme
|
||||||
117
transform/models/tap_spreadsheets_anywhere/time_registration.sql
Normal file
117
transform/models/tap_spreadsheets_anywhere/time_registration.sql
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
{{
|
||||||
|
config(
|
||||||
|
materialized='table'
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
-- This model explodes the absenteism overview into a daily time registration per Belgian workday
|
||||||
|
-- covering all records in `raw.absenteisme` (starting June 2024) and maps them to workers.
|
||||||
|
|
||||||
|
with abs as (
|
||||||
|
select
|
||||||
|
ax_nummer::text as ax_nummer,
|
||||||
|
to_date(begindatum_historische_rubrieken, 'YYYY-MM-DD')::date as period_start,
|
||||||
|
to_date(einddatum_historische_rubrieken, 'YYYY-MM-DD')::date as period_end,
|
||||||
|
coalesce("0120_gewaarborgd_maandloon_ziekte", 0)::int as paid_sick_days,
|
||||||
|
coalesce("0500_gelijkgestelde_dag_ziekte", 0)::int as unpaid_sick_days
|
||||||
|
from {{ source('tap_spreadsheets_anywhere', 'absenteisme') }}
|
||||||
|
where begindatum_historische_rubrieken is not null
|
||||||
|
),
|
||||||
|
|
||||||
|
calendar as (
|
||||||
|
-- generate every calendar day of each record's date range
|
||||||
|
select
|
||||||
|
a.ax_nummer,
|
||||||
|
a.period_start,
|
||||||
|
a.period_end,
|
||||||
|
a.paid_sick_days,
|
||||||
|
a.unpaid_sick_days,
|
||||||
|
generate_series(
|
||||||
|
a.period_start,
|
||||||
|
a.period_end,
|
||||||
|
interval '1 day'
|
||||||
|
)::date as date
|
||||||
|
from abs a
|
||||||
|
),
|
||||||
|
|
||||||
|
holidays as (
|
||||||
|
-- Hard‑coded Belgian public holidays for 2024‑2025
|
||||||
|
select date '2024-01-01' as holiday_date union all
|
||||||
|
select date '2024-04-01' union all
|
||||||
|
select date '2024-05-01' union all
|
||||||
|
select date '2024-05-09' union all
|
||||||
|
select date '2024-05-20' union all
|
||||||
|
select date '2024-07-21' union all
|
||||||
|
select date '2024-08-15' union all
|
||||||
|
select date '2024-11-01' union all
|
||||||
|
select date '2024-11-11' union all
|
||||||
|
select date '2024-12-25' union all
|
||||||
|
select date '2025-01-01' union all
|
||||||
|
select date '2025-04-21' union all
|
||||||
|
select date '2025-05-01' union all
|
||||||
|
select date '2025-05-29' union all
|
||||||
|
select date '2025-06-09' union all
|
||||||
|
select date '2025-07-21' union all
|
||||||
|
select date '2025-08-15' union all
|
||||||
|
select date '2025-11-01' union all
|
||||||
|
select date '2025-11-11' union all
|
||||||
|
select date '2025-12-25'
|
||||||
|
),
|
||||||
|
|
||||||
|
workdays as (
|
||||||
|
-- Filter to Belgian working days (Mon‑Fri excluding public holidays)
|
||||||
|
select
|
||||||
|
c.ax_nummer,
|
||||||
|
c.period_start,
|
||||||
|
c.date,
|
||||||
|
c.paid_sick_days,
|
||||||
|
c.unpaid_sick_days
|
||||||
|
from calendar c
|
||||||
|
left join holidays h on c.date = h.holiday_date
|
||||||
|
where extract(dow from c.date) not in (0, 6) -- 0 = Sunday, 6 = Saturday
|
||||||
|
and h.holiday_date is null
|
||||||
|
),
|
||||||
|
|
||||||
|
indexed as (
|
||||||
|
-- Give each workday an index within its record for sick‑day allocation
|
||||||
|
select
|
||||||
|
w.*,
|
||||||
|
row_number() over (partition by ax_nummer, period_start order by date) as rn
|
||||||
|
from workdays w
|
||||||
|
),
|
||||||
|
|
||||||
|
typed as (
|
||||||
|
-- Translate the indices into the requested day type
|
||||||
|
select
|
||||||
|
w.date,
|
||||||
|
8 as hours,
|
||||||
|
100 as percentage_workday,
|
||||||
|
case
|
||||||
|
when rn <= paid_sick_days then 'Paid sick day'
|
||||||
|
when rn <= paid_sick_days + unpaid_sick_days then 'Unpaid sick day'
|
||||||
|
else 'Work'
|
||||||
|
end as type,
|
||||||
|
w.ax_nummer
|
||||||
|
from indexed w
|
||||||
|
),
|
||||||
|
|
||||||
|
with_workers as (
|
||||||
|
-- Map to the worker table, stripping leading 0s from the HRIS id
|
||||||
|
select
|
||||||
|
t.*,
|
||||||
|
wk.id as worker_id
|
||||||
|
from typed t
|
||||||
|
join {{ ref('worker') }} wk
|
||||||
|
on regexp_replace(wk.worker_hris_id, '^0+', '') = t.ax_nummer
|
||||||
|
)
|
||||||
|
|
||||||
|
select
|
||||||
|
row_number() over (order by worker_id, date) as id,
|
||||||
|
date,
|
||||||
|
hours,
|
||||||
|
percentage_workday,
|
||||||
|
type,
|
||||||
|
worker_id
|
||||||
|
from with_workers
|
||||||
|
order by worker_id, date
|
||||||
Reference in New Issue
Block a user