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

Enable state ECPS runs #2009

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
added:
- dataset descriptor to various endpoints and controllers enabling enhanced CPS runs for any specified region
25 changes: 25 additions & 0 deletions policyengine_api/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ def build_microsimulation_options(self) -> dict:
dict(name=2028, label="2028"),
dict(name=2029, label="2029"),
]
datasets = [{}]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
elif self.country_id == "us":
region = [
dict(name="us", label="the US"),
# enhanced_us is a legacy option maintained for users
# accessing via an outdated URL
dict(name="enhanced_us", label="the US (enhanced CPS)"),
dict(name="al", label="Alabama"),
dict(name="ak", label="Alaska"),
Expand Down Expand Up @@ -153,35 +157,56 @@ def build_microsimulation_options(self) -> dict:
dict(name=2023, label="2023"),
dict(name=2022, label="2022"),
]
datasets = [
dict(
name="cps",
label="CPS",
title="Current Population Survey",
default=True,
),
dict(
name="enhanced_cps",
label="enhanced CPS",
title="Enhanced Current Population Survey",
default=False,
),
]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
elif self.country_id == "ca":
region = [
dict(name="ca", label="Canada"),
]
time_period = [
dict(name=2023, label="2023"),
]
datasets = [{}]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
elif self.country_id == "ng":
region = [
dict(name="ng", label="Nigeria"),
]
time_period = [
dict(name=2023, label="2023"),
]
datasets = [{}]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
elif self.country_id == "il":
region = [
dict(name="il", label="Israel"),
]
time_period = [
dict(name=2023, label="2023"),
]
datasets = [{}]
options["region"] = region
options["time_period"] = time_period
options["datasets"] = datasets
return options

def build_variables(self) -> dict:
Expand Down
4 changes: 4 additions & 0 deletions policyengine_api/data/initialise.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CREATE TABLE IF NOT EXISTS reform_impact (
reform_policy_id INT NOT NULL,
country_id VARCHAR(3) NOT NULL,
region VARCHAR(32) NOT NULL,
dataset VARCHAR(255) NOT NULL,
time_period VARCHAR(32) NOT NULL,
options_json JSON,
options_hash VARCHAR(255),
Expand All @@ -64,6 +65,8 @@ CREATE TABLE IF NOT EXISTS analysis (
status VARCHAR(32) NOT NULL
)

-- The dataset row below was added while the table is in prod;
-- we must allow NULL values for this column
CREATE TABLE IF NOT EXISTS user_policies (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
country_id VARCHAR(3) NOT NULL,
Expand All @@ -74,6 +77,7 @@ CREATE TABLE IF NOT EXISTS user_policies (
user_id VARCHAR(255) NOT NULL,
year VARCHAR(32) NOT NULL,
geography VARCHAR(255) NOT NULL,
dataset VARCHAR(255),
number_of_provisions INTEGER NOT NULL,
api_version VARCHAR(32) NOT NULL,
added_date BIGINT NOT NULL,
Expand Down
4 changes: 4 additions & 0 deletions policyengine_api/data/initialise_local.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ CREATE TABLE IF NOT EXISTS reform_impact (
reform_policy_id INT NOT NULL,
country_id VARCHAR(3) NOT NULL,
region VARCHAR(32) NOT NULL,
dataset VARCHAR(255) NOT NULL,
time_period VARCHAR(32) NOT NULL,
options_json JSON NOT NULL,
options_hash VARCHAR(255) NOT NULL,
Expand All @@ -73,6 +74,8 @@ CREATE TABLE IF NOT EXISTS analysis (
status VARCHAR(32) NOT NULL
);

-- The dataset row below was added while the table is in prod;
-- we must allow NULL values for this column
CREATE TABLE IF NOT EXISTS user_policies (
id INTEGER PRIMARY KEY,
country_id VARCHAR(3) NOT NULL,
Expand All @@ -83,6 +86,7 @@ CREATE TABLE IF NOT EXISTS user_policies (
user_id VARCHAR(255) NOT NULL,
year VARCHAR(32) NOT NULL,
geography VARCHAR(255) NOT NULL,
dataset VARCHAR(255),
number_of_provisions INTEGER NOT NULL,
api_version VARCHAR(32) NOT NULL,
added_date BIGINT NOT NULL,
Expand Down
Loading
Loading