-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/dim_teachers
- Loading branch information
Showing
11 changed files
with
201 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{# Notes: | ||
|
||
This macro is an attempt to engage in some DRY practice - to remove repeticious hard-coded labels for | ||
school, teacher, etc. activity. | ||
|
||
We have a method for determining whether a school, teacher, section is "active" (see: dim_school_status) The method produces a | ||
3-digit binary code. The key is below. This method is used in several locations where a label e.g. "active new" | ||
is applided. | ||
|
||
These 3 values can be combined into an ordered 3-char string representing the concatenated true/false combinations | ||
for Active|Prev|Ever e.g. "101" means: ( Active = true AND Prev year = false AND Ever before = true ) | ||
|
||
- '000' (0) = 'market' -- Not active now + never been active | ||
- '001' (1) = 'inactive churn' -- NOT active + NOT active prev year + active ever before | ||
- '010' (2) = '<impossible status>' -- should not be possible, active in the prev year should imply active ever before | ||
- '011' (3) = 'inactive this year' -- NOT active + active prev year + (active ever before implied) | ||
- '100' (4) = 'active new' -- active this year + NOT active last year + NOT active ever before | ||
- '101' (5) = 'active reacquired' -- Active this year + NOT active last year + active in the past | ||
- '110' (6) = '<impossible status>' -- impossible for same reason as status (2) | ||
- '111' (7) = 'active retained' -- active this year + active last year + (active ever before implied) | ||
#} | ||
|
||
{% macro active_status_label(status_code) %} | ||
|
||
case | ||
when {{status_code}} = '000' then 'market' | ||
when {{status_code}} = '001' then 'inactive churn' | ||
when {{status_code}} = '010' then '<impossible status>' | ||
when {{status_code}} = '011' then 'inactive this year' | ||
when {{status_code}} = '100' then 'active new' | ||
when {{status_code}} = '101' then 'active reacquired' | ||
when {{status_code}} = '110' then '<impossible status>' | ||
when {{status_code}} = '111' then 'active retained' | ||
when {{status_code}} IS NULL then NULL --on the fence about whether this should pass-thru the null, or whether we should be noisey about it | ||
else then 'INVALID CODE: ' || {{status_code}} | ||
end | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{# | ||
background/description: | ||
nces school ids should either be 12 characters (public) or 8 characters (private/charter) | ||
sometimes the leading zeros are dropped in which case we left pad the result. | ||
|
||
POTENTIAL FUTURE SAFE GUARD: | ||
- it's theoretically possible for nces ids to have more than 1 leading zero. | ||
- currently many of the 8-char school ids have as many is 5 leading zeros, for example. | ||
- none of the 12-char ids to date have more than 1 leading zero, but I'm unsure whether that is hard and fast rule | ||
- We should EITHER put some kind of test in to ensure that any school_ids are either 8 or 12 characters OR ensure that this macro handles it. | ||
|
||
1.22.24 - however, I'm not baking that safe-guard in here because I haven't researched the true rules of nces id lengths. So for now, just handling the one known case for length 11 | ||
#} | ||
|
||
-- Left pad school_id with 0s | ||
{% macro pad_school_id(school_id) %} | ||
case | ||
when length({{ school_id }}) = 11 then lpad({{ school_id }}, 12, '0') | ||
ELSE {{ school_id }} | ||
END | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.