Skip to content

Commit

Permalink
update non standard importers to convert to new area type
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Dec 11, 2023
1 parent dd35470 commit 44fa046
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
6 changes: 6 additions & 0 deletions hub/management/commands/import_hnh_polling_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tqdm import tqdm

from hub.models import Area, AreaData, DataSet, DataType
from hub.transformers import DataTypeConverter

from .base_importers import BaseImportFromDataFrameCommand

Expand Down Expand Up @@ -408,6 +409,11 @@ def extract_and_save_data(self):
defaults={"data": value},
)

converter = DataTypeConverter()
for data_type in data_types.values():
if data_type.area_type == converter.old_area_type:
converter.convert_datatype_to_new_geography(data_type)

def delete_data(self):
self.log("Deleting existing AreaData objects for DataTypes:")
for file in self.files:
Expand Down
36 changes: 16 additions & 20 deletions hub/management/commands/import_onward_polling_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,31 @@ class Command(BaseImportFromDataFrameCommand):

data_sets = {
"constituency_nz_support": {
"defaults": defaults.copy().extend(
{
"description": "Estimated percentage of constituents who support net zero."
}
),
"defaults": {
**defaults,
"description": "Estimated percentage of constituents who support net zero.",
},
"col": "support net zero",
},
"constituency_nz_neutral": {
"defaults": defaults.extend(
{
"description": "Estimated percentage of constituents who neither support nor oppose net zero."
}
),
"defaults": {
**defaults,
"description": "Estimated percentage of constituents who neither support nor oppose net zero.",
},
"col": "neither support nor oppose net zero",
},
"constituency_nz_oppose": {
"defaults": defaults.extend(
{
"description": "Estimated percentage of constituents who oppose net zero."
}
),
"defaults": {
**defaults,
"description": "Estimated percentage of constituents who oppose net zero.",
},
"col": "oppose net zero",
},
"constituency_cc_high": {
"defaults": defaults.copy().extend(
{
"description": "Estimated percentage of constituents who consider climate change a high priority."
}
),
"defaults": {
**defaults,
"description": "Estimated percentage of constituents who consider climate change a high priority.",
},
"col": "consider climate change a high priority",
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Command(BaseImportFromDataFrameCommand):
],
"data_url": "",
"comparators": DataSet.in_comparators(),
"data_type": "text",
}

data_sets = {
Expand Down

0 comments on commit 44fa046

Please sign in to comment.