machine icon indicating copy to clipboard operation
machine copied to clipboard

New attribute function for extracting single value for multivalued fields

Open macieg opened this issue 5 years ago • 6 comments

Currently available attribute functions don't allow to get a single value if a field has many of them. Good example might be Poland:

      <prg-ad:jednostkaAdmnistracyjna>Polska</prg-ad:jednostkaAdmnistracyjna>
      <prg-ad:jednostkaAdmnistracyjna>kujawsko-pomorskie</prg-ad:jednostkaAdmnistracyjna>
      <prg-ad:jednostkaAdmnistracyjna>brodnicki</prg-ad:jednostkaAdmnistracyjna>
      <prg-ad:jednostkaAdmnistracyjna>Bartniczka</prg-ad:jednostkaAdmnistracyjna>

This is a part of a single address record. It contains many values for a key "prg-ad:jednostkaAdmnistracyjna". Region is always the second value here (kujawsko-pomorskie in this case).

I propose adding a new attribute function called i.e just get to extract single value.

            "conform": {
                "region": {
                    "function": "get",
                    "field": "jednostkaAdministracyjna",
                    "index": 1
                }
            }

macieg avatar Apr 18 '20 14:04 macieg

The PR is here - https://github.com/openaddresses/machine/pull/767

macieg avatar Apr 18 '20 14:04 macieg

There was a wrong import https://github.com/openaddresses/machine/pull/769 @iandees please approve

macieg avatar May 10 '20 19:05 macieg

@iandees Another one... Could you guide me how to run CI before merge? https://github.com/openaddresses/machine/pull/770

macieg avatar May 12 '20 17:05 macieg

I think it should be running itself. @migurski am I remembering right that machine had CI tests?

iandees avatar May 12 '20 19:05 iandees

Not sure why the CI wasn't running on your branch, but you can follow these instructions to get tests running locally: https://github.com/openaddresses/machine/blob/master/docs/install.md#local-development

iandees avatar May 13 '20 14:05 iandees

Thanks for working through this!

iandees avatar May 13 '20 14:05 iandees