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

fix(web): Fix query for generic and team member lists #17115

Merged
merged 5 commits into from
Dec 10, 2024

Conversation

mannipje
Copy link
Member

@mannipje mannipje commented Dec 3, 2024

Fix query for generic and team member lists

What

  • Removed score for get list items
  • Sort only by order
  • Set the default operator on search query as 'and'
  • Add gereric tags to be searchable in generic list search
  • Add member title to be searchable in team member list search

Why

So the items in the list is not jumping around on search filtering the list of items.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Enhanced query processing with mandatory term presence in search results.
    • Improved content generation for list items and team members by including additional titles.
  • Bug Fixes

    • Refined error handling for missing vacancies to prevent unhandled exceptions.
  • Documentation

    • Updated method signatures to reflect changes in query handling and error management.

Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Walkthrough

The changes in this pull request involve modifications to several service classes within the CMS library. Key updates include enhancements to query handling in the CmsElasticsearchService, which now includes a default_operator: 'and' for query strings and improved error handling for missing vacancies. The GenericListItemSyncService and TeamListSyncService classes have also been updated to enhance content generation by incorporating additional data from filter tags and team member titles, respectively. Overall, the changes streamline logic and improve data processing across the services.

Changes

File Path Change Summary
libs/cms/src/lib/cms.elasticsearch.service.ts - Added default_operator: 'and' to simple_query_string in getListItems method.
- Updated queryString handling with trim().
- Simplified sorting logic to default to descending order by release date.
- Enhanced error handling in getSingleVacancy to return null for 404 errors.
libs/cms/src/lib/search/importers/genericListItem.service.ts - Added loop in doMapping method to include titles from mapped.filterTags in contentSections.
- Updated tags array construction to include filter tags as objects with type and key.
libs/cms/src/lib/search/importers/teamList.service.ts - Modified doMapping method to construct contentSection array for team members, including both intro and title.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • oddsson
  • Toti91

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mannipje mannipje added the deploy-feature Deploys features to dev label Dec 3, 2024
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Project coverage is 35.73%. Comparing base (a043d4c) to head (adc3863).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/cms/src/lib/search/importers/teamList.service.ts 0.00% 8 Missing ⚠️
libs/cms/src/lib/cms.elasticsearch.service.ts 0.00% 3 Missing ⚠️
...rc/lib/search/importers/genericListItem.service.ts 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17115      +/-   ##
==========================================
- Coverage   35.73%   35.73%   -0.01%     
==========================================
  Files        6928     6928              
  Lines      147817   147824       +7     
  Branches    42127    42129       +2     
==========================================
  Hits        52818    52818              
- Misses      94999    95006       +7     
Flag Coverage Δ
api 3.33% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.42% <0.00%> (-0.03%) ⬇️
application-system-api 38.76% <0.00%> (-0.01%) ⬇️
application-template-api-modules 27.81% <0.00%> (-0.01%) ⬇️
cms 0.40% <0.00%> (-0.01%) ⬇️
cms-translations 38.76% <0.00%> (-0.03%) ⬇️
judicial-system-api 19.97% <ø> (ø)
judicial-system-backend 55.75% <0.00%> (-0.02%) ⬇️
services-user-notification 46.59% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rc/lib/search/importers/genericListItem.service.ts 15.38% <0.00%> (-0.84%) ⬇️
libs/cms/src/lib/cms.elasticsearch.service.ts 2.86% <0.00%> (ø)
...s/cms/src/lib/search/importers/teamList.service.ts 15.00% <0.00%> (-2.15%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a043d4c...adc3863. Read the comment docs.

Copy link
Contributor

github-actions bot commented Dec 3, 2024

Affected services are: air-discount-scheme-api,api,application-system-api,judicial-system-api,judicial-system-backend,services-search-indexer,services-user-notification,
Feature deployment of your services will begin shortly. Your feature will be accessible here:
https://fixelastic-search-service-get-list-items-api-catalogue.dev01.devland.is/api
https://fixelastic-search-service-get-list-items-application-callback-xrd.internal.dev01.devland.is/application-payment
https://fixelastic-search-service-get-list-items-application-callback-xrd.internal.dev01.devland.is/applications
https://fixelastic-search-service-get-list-items-application-payment-callback-xrd.internal.dev01.devland.is/application-payment
https://fixelastic-search-service-get-list-items-application-payment-callback-xrd.internal.dev01.devland.is/applications
https://fixelastic-search-service-get-list-items-beta.dev01.devland.is/
https://fixelastic-search-service-get-list-items-beta.dev01.devland.is/api
https://fixelastic-search-service-get-list-items-beta.dev01.devland.is/bff
https://fixelastic-search-service-get-list-items-beta.dev01.devland.is/samradsgatt
https://fixelastic-search-service-get-list-items-beta.dev01.devland.is/stjornbord/bff
https://fixelastic-search-service-get-list-items-loftbru-cf.dev01.devland.is/
https://fixelastic-search-service-get-list-items-loftbru-cf.dev01.devland.is/api/graphql
https://fixelastic-search-service-get-list-items-loftbru.dev01.devland.is/
https://fixelastic-search-service-get-list-items-loftbru.dev01.devland.is/api/graphql

Deployed services: application-system-api,api,air-discount-scheme-api,application-system-api-worker,consultation-portal,web,services-bff-portals-admin,services-bff-portals-my-pages,air-discount-scheme-web.
Excluded services: search-indexer-service,user-notification,user-notification-worker,user-notification-cleanup-worker

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 3, 2024

Datadog Report

All test runs cec8121 🔗

10 Total Test Services: 0 Failed, 9 Passed
🔻 Test Sessions change in coverage: 2 decreased, 26 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.56s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 10.4s 1 no change Link
api-domains-communications 0 0 0 5 0 36.35s 1 decreased (-0.02%) Link
api-domains-license-service 0 0 0 0 0 749.32ms 1 no change Link
application-system-api 0 0 0 46 0 2m 19.01s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 5.33s 1 no change Link
cms-translations 0 0 0 3 0 32.33s 1 decreased (-0.02%) Link
judicial-system-api 0 0 0 61 0 7.33s 1 no change Link
judicial-system-backend 0 0 0 21150 0 24m 13.75s 1 no change Link
services-user-notification 0 0 0 51 0 1m 35.97s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • api-domains-communications - jest 48.59% (-0.02%) - Details
  • cms-translations - jest 48.24% (-0.02%) - Details

@mannipje mannipje marked this pull request as ready for review December 9, 2024 15:02
@mannipje mannipje requested review from a team as code owners December 9, 2024 15:02
@mannipje mannipje added deprecated:automerge (Disabled) Merge this PR as soon as all checks pass and removed deploy-feature Deploys features to dev labels Dec 9, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
libs/cms/src/lib/search/importers/teamList.service.ts (1)

34-43: LGTM! Consider adding null checks for content sections.

The new content generation approach using an array to combine multiple sections is a good improvement. It makes the content more comprehensive by including both the intro and title.

Consider adding null/undefined checks before pushing content sections:

-contentSection.push(
-  memberEntry?.fields?.intro
-    ? documentToPlainTextString(memberEntry.fields.intro)
-    : '',
-)
+if (memberEntry?.fields?.intro) {
+  contentSection.push(documentToPlainTextString(memberEntry.fields.intro))
+}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 02f2aa4 and a4d716b.

📒 Files selected for processing (3)
  • libs/cms/src/lib/cms.elasticsearch.service.ts (2 hunks)
  • libs/cms/src/lib/search/importers/genericListItem.service.ts (1 hunks)
  • libs/cms/src/lib/search/importers/teamList.service.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
libs/cms/src/lib/search/importers/genericListItem.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/cms/src/lib/search/importers/teamList.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/cms/src/lib/cms.elasticsearch.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (3)
libs/cms/src/lib/search/importers/genericListItem.service.ts (1)

54-56: LGTM! Content enhancement with filter tags.

The addition of filter tag titles to the content sections improves searchability and maintains consistency with the team list implementation.

libs/cms/src/lib/cms.elasticsearch.service.ts (2)

512-514: LGTM! Improved query string normalization.

The addition of trim() and consistent case handling improves search reliability by normalizing input.


525-525: Verify the impact of stricter query matching.

The addition of default_operator: 'and' makes search more precise by requiring all terms to match. This aligns with the PR objective to prevent unexpected item rearrangement.

Let's verify the query behavior:

✅ Verification successful

The default_operator: 'and' change is consistent with existing implementations

The verification shows that this change aligns with existing search behavior in the codebase. The same configuration is already used in libs/content-search-toolkit/src/queries/search.ts, indicating this is a standardized approach across the application. Other search implementations either already use the 'and' operator or are specialized for different use cases (like wildcard searches in the API catalogue).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for existing query string usage to assess impact

# Search for query string configurations
rg -A 5 'simple_query_string' --type ts

Length of output: 1928


Script:

#!/bin/bash
# Let's check for any test files or specs that might verify the search behavior
rg -l "test|spec" --type ts | rg -i "search|elasticsearch"

# Also check for any documentation about the search functionality
fd -e md | xargs rg -l "search|query"

Length of output: 2815

@kodiakhq kodiakhq bot merged commit 1073e70 into main Dec 10, 2024
61 checks passed
@kodiakhq kodiakhq bot deleted the fix/elastic-search-service-get-list-items branch December 10, 2024 09:16
thorhildurt pushed a commit that referenced this pull request Dec 11, 2024
* Fix query for generic and team member lists

* Add tags to be searchable in gengeric list search

* Add title to be searchable in team member list search

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
RunarVestmann pushed a commit that referenced this pull request Jan 8, 2025
* Fix query for generic and team member lists

* Add tags to be searchable in gengeric list search

* Add title to be searchable in team member list search

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kodiakhq bot added a commit that referenced this pull request Jan 9, 2025
* fix(web): Fix query for generic and team member lists (#17115)

* Fix query for generic and team member lists

* Add tags to be searchable in gengeric list search

* Add title to be searchable in team member list search

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(web): Sort by title for generic list and team list (#17226)

* Add title.sort again

* No need to have _score type

---------

Co-authored-by: mannipje <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants