-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1296 from uktrade/IGUK-200_Sectors
Iguk 200 sectors
- Loading branch information
Showing
11 changed files
with
407 additions
and
0 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
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
53 changes: 53 additions & 0 deletions
53
dataservices/management/commands/import_dbt_investment_opportunities.py
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,53 @@ | ||
import pandas as pd | ||
import sqlalchemy as sa | ||
|
||
from dataservices.models import DBTInvestmentOpportunity | ||
|
||
from .helpers import BaseDataWorkspaceIngestionCommand | ||
|
||
|
||
class Command(BaseDataWorkspaceIngestionCommand): | ||
help = 'Import DBT investment opportunities data from Data Workspace' | ||
sql = ''' | ||
SELECT | ||
id, | ||
updated_date, | ||
investment_opportunity_code, | ||
opportunity_title, | ||
description, | ||
nomination_round, | ||
launched, | ||
opportunity_type, | ||
location, | ||
sub_sector, | ||
levelling_up, | ||
net_zero, | ||
science_technology_superpower, | ||
sector_cluster | ||
FROM public.dit_investment_opportunities | ||
''' | ||
|
||
def load_data(self): | ||
data = [] | ||
chunks = pd.read_sql(sa.text(self.sql), self.engine, chunksize=5000) | ||
|
||
for chunk in chunks: | ||
|
||
for _idx, row in chunk.iterrows(): | ||
data.append( | ||
DBTInvestmentOpportunity( | ||
opportunity_title=row.opportunity_title, | ||
description=row.description, | ||
nomination_round=row.nomination_round, | ||
launched=row.launched, | ||
opportunity_type=row.opportunity_type, | ||
location=row.location, | ||
sub_sector=row.sub_sector, | ||
levelling_up=row.levelling_up, | ||
net_zero=row.net_zero, | ||
science_technology_superpower=row.science_technology_superpower, | ||
sector_cluster=row.sector_cluster, | ||
) | ||
) | ||
|
||
return data |
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,45 @@ | ||
import pandas as pd | ||
import sqlalchemy as sa | ||
|
||
from dataservices.models import DBTSector | ||
|
||
from .helpers import BaseDataWorkspaceIngestionCommand | ||
|
||
|
||
class Command(BaseDataWorkspaceIngestionCommand): | ||
help = 'Import DBT sector list data from Data Workspace' | ||
sql = ''' | ||
SELECT | ||
id, | ||
updated_date, | ||
field_01, | ||
field_03, | ||
full_sector_name, | ||
field_04, | ||
field_05, | ||
field_02, | ||
field_06, | ||
field_07, | ||
sector_cluster__april_2023 | ||
FROM public.ref_dit_sectors | ||
''' | ||
|
||
def load_data(self): | ||
data = [] | ||
chunks = pd.read_sql(sa.text(self.sql), self.engine, chunksize=5000) | ||
|
||
for chunk in chunks: | ||
|
||
for _idx, row in chunk.iterrows(): | ||
data.append( | ||
DBTSector( | ||
sector_id=row.field_01, | ||
full_sector_name=row.full_sector_name, | ||
sector_cluster_name=row.sector_cluster__april_2023, | ||
sector_name=row.field_04, | ||
sub_sector_name=row.field_05, | ||
sub_sub_sector_name=row.field_02, | ||
) | ||
) | ||
|
||
return data |
53 changes: 53 additions & 0 deletions
53
dataservices/management/commands/import_sectors_gva_value_bands.py
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,53 @@ | ||
import pandas as pd | ||
import sqlalchemy as sa | ||
|
||
from dataservices.models import SectorGVAValueBand | ||
|
||
from .helpers import BaseDataWorkspaceIngestionCommand | ||
|
||
|
||
class Command(BaseDataWorkspaceIngestionCommand): | ||
help = 'Import sector GVA value bands data from Data Workspace' | ||
sql = ''' | ||
SELECT | ||
id, | ||
updated_date, | ||
sector_gva_and_value_band_id, | ||
full_sector_name, | ||
gva_grouping, | ||
gva_multiplier, | ||
value_band_a_minimum, | ||
value_band_b_minimum, | ||
value_band_c_minimum, | ||
value_band_d_minimum, | ||
value_band_e_minimum, | ||
sector_classification_value_band, | ||
sector_classification_gva_multiplier, | ||
start_date, | ||
end_date | ||
FROM public.ref_sectors_gva_value_bands | ||
''' | ||
|
||
def load_data(self): | ||
data = [] | ||
chunks = pd.read_sql(sa.text(self.sql), self.engine, chunksize=5000) | ||
|
||
for chunk in chunks: | ||
|
||
for _idx, row in chunk.iterrows(): | ||
data.append( | ||
SectorGVAValueBand( | ||
full_sector_name=row.full_sector_name, | ||
value_band_a_minimum=row.value_band_a_minimum, | ||
value_band_b_minimum=row.value_band_b_minimum, | ||
value_band_c_minimum=row.value_band_c_minimum, | ||
value_band_d_minimum=row.value_band_d_minimum, | ||
value_band_e_minimum=row.value_band_e_minimum, | ||
start_date=row.start_date, | ||
end_date=row.end_date, | ||
sector_classification_value_band=row.sector_classification_value_band, | ||
sector_classification_gva_multiplier=row.sector_classification_gva_multiplier, | ||
) | ||
) | ||
|
||
return data |
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
58 changes: 58 additions & 0 deletions
58
dataservices/migrations/0055_dbtinvestmentopportunity_dbtsector_and_more.py
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,58 @@ | ||
# Generated by Django 4.2.11 on 2024-07-25 08:17 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dataservices', '0054_eybsalarydata_occupation_eybsalarydata_soc_code'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='DBTInvestmentOpportunity', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('opportunity_title', models.CharField()), | ||
('description', models.CharField()), | ||
('nomination_round', models.FloatField()), | ||
('launched', models.BooleanField()), | ||
('opportunity_type', models.CharField()), | ||
('location', models.CharField()), | ||
('sub_sector', models.CharField()), | ||
('levelling_up', models.BooleanField()), | ||
('net_zero', models.BooleanField()), | ||
('science_technology_superpower', models.BooleanField()), | ||
('sector_cluster', models.CharField()), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='DBTSector', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('sector_id', models.CharField()), | ||
('full_sector_name', models.CharField()), | ||
('sector_cluster_name', models.CharField()), | ||
('sector_name', models.CharField()), | ||
('sub_sector_name', models.CharField(blank=True, null=True)), | ||
('sub_sub_sector_name', models.CharField(blank=True, null=True)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='SectorGVAValueBand', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('full_sector_name', models.CharField()), | ||
('value_band_a_minimum', models.IntegerField()), | ||
('value_band_b_minimum', models.IntegerField()), | ||
('value_band_c_minimum', models.IntegerField()), | ||
('value_band_d_minimum', models.IntegerField()), | ||
('value_band_e_minimum', models.IntegerField()), | ||
('start_date', models.DateField()), | ||
('end_date', models.DateField()), | ||
('sector_classification_value_band', models.CharField()), | ||
('sector_classification_gva_multiplier', models.CharField()), | ||
], | ||
), | ||
] |
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.