Skip to content

Commit

Permalink
Add enricher, bump transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Apr 9, 2024
1 parent 7115a94 commit 91d49ab
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ national-budget-changes:
parameters:
name: national-budget-changes
title: National Budget Amendments
revision: 2024.04-09
- run: load
parameters:
from: https://budgetkey-files.ams3.digitaloceanspaces.com/yearly-budgets/BudgetChanges_past_approv_data_2005.xlsx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,60 +449,60 @@ def stats(self):
WHERE apm='יש אישור'
"""
),
# Enricher('85297: Pct has article 46 by field of activity',
# 'association', ('field_of_activity', ),
# [
# {
# 'name': 'pct_has_article_46_in_field_of_activity',
# 'type': 'integer'
# }
# ],
# """
# WITH a AS
# (SELECT association_field_of_activity,
# association_has_article_46 AS aha,
# count(1) AS cnt
# FROM guidestar_processed
# GROUP BY 1,
# 2),
# b AS
# (SELECT association_field_of_activity,
# count(1) AS cnt
# FROM guidestar_processed
# GROUP BY 1)
# SELECT association_field_of_activity AS field_of_activity,
# (100*a.cnt)/b.cnt AS pct_has_article_46_in_field_of_activity
# FROM a
# JOIN b USING (association_field_of_activity)
# WHERE aha='יש אישור'
# """
# ),
# Enricher('85905: Association median top salary by field of activity',
# 'association', ('field_of_activity', ),
# [
# {
# 'name': 'median_top_salary',
# 'type': 'number'
# }
# ],
# """
# WITH a AS
# (SELECT association_field_of_activity AS foa,
# ((association_top_salaries->>0)::jsonb->>'salary')::numeric AS top_salary
# FROM guidestar_processed
# WHERE association_status_active
# AND jsonb_array_length(association_top_salaries)>0
# ORDER BY 2),
# b AS
# (SELECT foa,
# array_agg(top_salary) AS top_salaries
# FROM a
# GROUP BY 1)
# SELECT foa as field_of_activity,
# top_salaries[ceil(array_length(top_salaries, 1)/2)+1] AS median_top_salary
# FROM b
# """
# ),
Enricher('85297: Pct has article 46 by field of activity',
'association', ('field_of_activity', ),
[
{
'name': 'pct_has_article_46_in_field_of_activity',
'type': 'integer'
}
],
"""
WITH a AS
(SELECT association_field_of_activity,
association_has_article_46 AS aha,
count(1) AS cnt
FROM guidestar_processed
GROUP BY 1,
2),
b AS
(SELECT association_field_of_activity,
count(1) AS cnt
FROM guidestar_processed
GROUP BY 1)
SELECT association_field_of_activity AS field_of_activity,
(100*a.cnt)/b.cnt AS pct_has_article_46_in_field_of_activity
FROM a
JOIN b USING (association_field_of_activity)
WHERE aha='יש אישור'
"""
),
Enricher('85905: Association median top salary by field of activity',
'association', ('field_of_activity', ),
[
{
'name': 'median_top_salary',
'type': 'number'
}
],
"""
WITH a AS
(SELECT association_field_of_activity AS foa,
((association_top_salaries->>0)::jsonb->>'salary')::numeric AS top_salary
FROM guidestar_processed
WHERE association_status_active
AND jsonb_array_length(association_top_salaries)>0
ORDER BY 2),
b AS
(SELECT foa,
array_agg(top_salary) AS top_salaries
FROM a
GROUP BY 1)
SELECT foa as field_of_activity,
top_salaries[ceil(array_length(top_salaries, 1)/2)+1] AS median_top_salary
FROM b
"""
),
]


Expand Down

0 comments on commit 91d49ab

Please sign in to comment.