Skip to content

Commit

Permalink
Add support helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Jun 27, 2024
1 parent b6f2e21 commit 556060d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from datapackage_pipelines.wrapper import process


def process_row(row, _1, spec, _2, params, _3):
if spec['name'] == 'supports':
payments = row.get('payments', [])
if payments:
row['support_title'] = payments[0].get('support_title')
row['supporting_ministry'] = payments[0].get('supporting_ministry', '')

return row


def modify_datapackage(dp, params, *_):
for res in dp['resources']:
if res['name'] == 'supports':
res['schema']['fields'].append({
'name': 'support_title',
'type': 'string',
'es:title': True
})
res['schema']['fields'].append({
'name': 'supporting_ministry',
'type': 'string',
'es:keyword': True
})
return dp


if __name__ == '__main__':
process(modify_datapackage=modify_datapackage,
process_row=process_row)
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ supports:
resource: supports
source-field: budget_code
target-field: 'nice-budget-code'
- run: add_support_helpers
# keep-history:
# -
# key: payments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def debug_source(source, debug):
search=dict(
index='supports',
field_map={
'budget_code': 'nice-code',
'budget_code': 'nice-budget-code',
'purpose': 'support_title',
'supporting_ministry': 'supporting_ministry',
'request_type': 'request_type',
Expand Down

0 comments on commit 556060d

Please sign in to comment.