Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-10774: news location #843

Merged
merged 4 commits into from
Nov 14, 2024
Merged

UHF-10774: news location #843

merged 4 commits into from
Nov 14, 2024

Conversation

hyrsky
Copy link
Contributor

@hyrsky hyrsky commented Nov 12, 2024

UHF-10774

What was done

  • Add geo_point to news and news neighbourhood elasticsearch.
    • Add field that stores coordinates
    • Add search_api support for location field.

How to install

  • Make sure your etusivu is up and running on branch UHF-10774-news-location.
    • git checkout UHF-10774-news-location
  • Update the Helfi Platform config
    • composer require drupal/helfi_platform_config:dev-UHF-10774-news-location
  • Run make fresh

How to test

  • Run drush sapi-rt; drush sapi-c; drush sapi-i
  • Existing news search should work as before
  • Try filtering news with location. Example queries:
curl 'https://elastic-proxy-helfi-etusivu.docker.so/news/_search' -X POST -H 'Content-Type: application/json' --data-raw '{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "entity_type":"taxonomy_term"
          }
        },
        {
          "term": {
            "search_api_language":"fi"
          }
        }
      ]
    }
  },
  "sort": [
    {
      "_geo_distance": {
        "field_location": {
          "lat": 60.187959,
          "lon": 24.966060
        },
        "order": "asc",
        "unit": "km",
        "mode": "min",
        "ignore_unmapped": true
      }
    }
  ],
  "size": 10
}' | jq
curl 'https://elastic-proxy-helfi-etusivu.docker.so/news/_search' -X POST -H 'Content-Type: application/json' --data-raw '{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "entity_type":"node"
          }
        },
        {
          "term": {
            "search_api_language":"fi"
          }
        }
      ]
    }
  },
  "sort": [
    {
      "_geo_distance": {
        "news_location": {
          "lat": 60.187959,
          "lon": 24.966060
        },
        "order": "asc",
        "unit": "km",
        "mode": "min",
        "ignore_unmapped": true
      }
    }
  ],
  "size": 10
}' | jq
  • Check that code follows our standards

Continuous documentation

  • This feature has been documented/the documentation has been updated
  • This change doesn't require updates to the documentation

Translations

  • Translations have been added to .po -files and included in this PR

Other PRs

@hyrsky hyrsky force-pushed the UHF-10774-news-location branch from 80d2a81 to b9feab6 Compare November 12, 2024 06:56
@hyrsky hyrsky force-pushed the UHF-10774-news-location branch 3 times, most recently from 51850cf to 7f32184 Compare November 12, 2024 11:34
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 35.80247% with 52 lines in your changes missing coverage. Please review.

Project coverage is 16.60%. Comparing base (bb50a52) to head (7f32184).
Report is 232 commits behind head on main.

Files with missing lines Patch % Lines
src/Plugin/Field/FieldWidget/LocationWidget.php 0.00% 26 Missing ⚠️
.../Field/FieldFormatter/LocationDefaultFormatter.php 0.00% 15 Missing ⚠️
src/TypedData/LocationDataDefinition.php 0.00% 5 Missing ⚠️
src/EventSubscriber/SearchApiSubscriber.php 55.55% 4 Missing ⚠️
src/Plugin/Field/FieldType/LocationItem.php 92.30% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #843      +/-   ##
============================================
+ Coverage     15.29%   16.60%   +1.31%     
- Complexity      259      275      +16     
============================================
  Files            31       34       +3     
  Lines           981     1048      +67     
============================================
+ Hits            150      174      +24     
- Misses          831      874      +43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hyrsky hyrsky force-pushed the UHF-10774-news-location branch from 7f32184 to 51057be Compare November 13, 2024 07:00
@hyrsky hyrsky marked this pull request as ready for review November 13, 2024 07:01
Copy link

@juho-lehmonen juho-lehmonen self-requested a review November 13, 2024 07:25
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.

3 participants