Skip to content

Commit

Permalink
db: Export non_primary_org_ids in data package
Browse files Browse the repository at this point in the history
  • Loading branch information
R2ZER0 committed Oct 29, 2024
1 parent 996dadc commit 7a088d6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions datastore/db/management/commands/manage_entities_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

from additional_data.sources.find_that_charity import non_primary_org_ids_lookup_maps

data_types_reverse = DatabaseIntrospection.data_types_reverse.copy()
data_types_reverse.update({1009: "ArrayField"})


@transaction.atomic
def update_entities():
Expand Down Expand Up @@ -89,6 +92,7 @@ def create_orgs_list(entity_type, output=sys.stdout):
query = f"""
SELECT DISTINCT
db_{entity_type}.org_id as "id",
db_{entity_type}.non_primary_org_ids as "non_primary_org_ids",
db_{entity_type}.name as name,
db_{entity_type}."aggregate" as "aggregate",
db_{entity_type}.additional_data as "additionalData",
Expand All @@ -115,9 +119,7 @@ def parse_data_in_result(result, col_types):
with connection.cursor() as cursor:
cursor.execute(query)
cols = [col.name for col in cursor.description]
col_types = [
introspect.data_types_reverse[col.type_code] for col in cursor.description
]
col_types = [data_types_reverse[col.type_code] for col in cursor.description]

for row in cursor.fetchall():
row_new = parse_data_in_result(row, col_types)
Expand Down

0 comments on commit 7a088d6

Please sign in to comment.