Skip to content

UHF-12531: Add Mobile Note sync#1222

Merged
sundflux merged 53 commits intodevfrom
UHF-12531
Feb 2, 2026
Merged

UHF-12531: Add Mobile Note sync#1222
sundflux merged 53 commits intodevfrom
UHF-12531

Conversation

@sundflux
Copy link
Contributor

@sundflux sundflux commented Jan 15, 2026

UHF-12531

What was done

  • Adds MobileNote data sync.

How to install

First, you will need following variables in local .env:

MN_WFS_USERNAME=xxx
MN_WFS_PASSWORD=xxx
MN_WFS_URL=https://kymp.mobilenote.fi/MobilenoteService/wfs
PAIKKATIETOHAKU_API_KEY=

Credentials in confluence.

  • Make sure your instance is up and running latest version of dev-branch
    • git checkout dev && git pull origin dev && git fetch
    • git checkout UHF-12531
    • make fresh
    • make shell -> composer require drupal/helfi_platform_config:dev-UHF-12531
    • make fresh
  • Now the setup should work.

How to test

  •  After installing, you can run the sync manually:
docker compose exec app drush cron

docker compose exec app drush sapi-c mobilenote_data

docker compose exec app drush sapi-r mobilenote_data

docker compose exec app drush sapi-i mobilenote_data

docker compose exec app drush sapi-s

docker compose exec app curl "http://elastic:9200/_search?q=*68209*&pretty"
docker compose exec elastic curl -s -X GET "localhost:9200/mobilenote_data/_search?pretty" -H 'Content-Type: application/json' -d '{
  "query": {
    "geo_shape": {
      "geometry": {
        "shape": {
          "type": "circle",
          "coordinates": [24.945, 60.17],
          "radius": "500m"
        },
        "relation": "intersects"
      }
    }
  },
  "size": 5
}'

or get one item:

docker compose exec elastic curl -s "localhost:9200/mobilenote_data/_search?pretty" -H 'Content-Type: application/json' -d '{
  "query": {"match_all": {}},
  "sort": [{"updated_at": "desc"}],
  "size": 1
}'
  • Check that the code follows our standards

Links to related PRs

* @param bool $fetchNearbyStreetData
* Whether to fetch street name data.
*
* @return array<int|string, \Drupal\Core\TypedData\ComplexDataInterface>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this return array<string, MobileNoteData>?

Comment on lines 145 to 146
$hasMethod = method_exists($item, 'get');
$geo = ($hasMethod) ? $item->get('geometry')->getValue() : NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is trying to be overly generic. Just call the get method and if it does not exist it is ok to crash. No need to work around possible bugs.


foreach ($data['results'] ?? [] as $result) {
if (!empty($result['street']['name']['fi'])) {
$streets[] = $result['street']['name']['fi'];
Copy link
Contributor

@hyrsky hyrsky Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should save the Swedish street name too. Just throw it into the index, maybe in a separate field?

* @return array<int|string, \Drupal\Core\TypedData\ComplexDataInterface>
* An array of MobileNote data items, keyed by ID.
*/
public function getMobileNoteData(bool $fetchNearbyStreetData = FALSE): array {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter is always false. Maybe remove since it is not used?

default:
indexing_order: fifo
options:
cron_limit: 50
Copy link
Contributor

@hyrsky hyrsky Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, cron_limit should be lowered, since the api has stability issues.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 2, 2026

@sundflux sundflux merged commit 0bdbc18 into dev Feb 2, 2026
3 checks passed
@sundflux sundflux deleted the UHF-12531 branch February 2, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants