localgovdrupal / localgov_outpost

Outpost directory integration for LocalGov Drupal
0 stars 0 forks source link

Cost options concatenation needs reviewing #18

Open finnlewis opened 9 months ago

finnlewis commented 9 months ago

Hi @ekes

On Greenwich Community Directory we are migrating in the Outpost data.

The cost options come into a single field, concatenated on migration.

Source data:

"cost_options": [
        {
          "id": 118,
          "option": "Adult",
          "amount": "5.00",
          "cost_type": "per day"
        }
      ],

Migration config:

  localgov_outpost_cost:
    plugin: sub_process
    source: cost_options
    include_source: true
    source_key: source
    process:
      value:
        plugin: concat
        source:
          - option
          - source/constants/CURRENCY
          - amount
          - cost_type
        delimiter: ''

Thus we end up with

 Adult£5.00per day

image

I think we need to

  1. add a space after the option,
  2. no space after the currency symbol
  3. add a space after the amount
  4. no space after the cost_type

How best to do this, in a Migrate process plugin?

finnlewis commented 9 months ago

Note that I removed the original space in the concat here: https://github.com/localgovdrupal/localgov_outpost/pull/9/files

finnlewis commented 9 months ago

Discussing with @ekes , suggesting that we can use a constant like follows:

process:
      value:
        plugin: concat
        source:
          - option
          - source/constants/SPACE
          - source/constants/CURRENCY
          - amount
          - source/constants/SPACE
          - cost_type
finnlewis commented 9 months ago

I will try it!