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

feat(web): Do not index org subpages that are 'standalone' #16717

Merged

Conversation

RunarVestmann
Copy link
Member

@RunarVestmann RunarVestmann commented Nov 5, 2024

Do not index org subpages that are 'standalone'

What

  • A new theme was added to the "Organization page" content type called 'standalone'
  • These types of organization pages will have their own search, meaning that we don't want them to be found elsewhere

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
    • Updated global search to exclude standalone organization pages from results, improving search relevance for users.

@RunarVestmann RunarVestmann added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Nov 5, 2024
@RunarVestmann RunarVestmann requested review from a team as code owners November 5, 2024 10:36
Copy link
Contributor

coderabbitai bot commented Nov 5, 2024

Walkthrough

The pull request modifies the processSyncData method in the OrganizationSubpageSyncService class to add a filtering condition that excludes organization pages with the theme property set to 'standalone'. This adjustment impacts the global search functionality by preventing standalone organization pages from appearing in search results, while maintaining the existing logic and structure of the method.

Changes

File Path Change Summary
libs/cms/src/lib/search/importers/organizationSubpage.service.ts Modified processSyncData method to add a condition that excludes organization pages with theme equal to 'standalone'.

Possibly related PRs

Suggested reviewers

  • mannipje

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.

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 (2)
libs/cms/src/lib/search/importers/organizationSubpage.service.ts (2)

25-27: Consider extracting the theme constant.

The implementation correctly filters out standalone organization pages. However, the 'standalone' string literal could be moved to a constant for better maintainability.

+const STANDALONE_THEME = 'standalone' as const;
+
 @Injectable()
 export class OrganizationSubpageSyncService
   implements CmsSyncProvider<IOrganizationSubpage>
 {
   processSyncData(entries: processSyncDataInput<IOrganizationSubpage>) {
     return entries.filter(
       (entry: Entry<any>): entry is IOrganizationSubpage =>
         entry.sys.contentType.sys.id === 'organizationSubpage' &&
         !!entry.fields.title &&
         !!entry.fields.slug &&
         !!entry.fields.organizationPage?.fields?.slug &&
-        entry.fields.organizationPage.fields.theme !== 'standalone',
+        entry.fields.organizationPage.fields.theme !== STANDALONE_THEME,
     )
   }

25-27: Consider using a more specific type than Entry<any>.

While the type guard ensures type safety, using Entry<any> in the filter callback could be more specific to improve type checking during development.

   processSyncData(entries: processSyncDataInput<IOrganizationSubpage>) {
     return entries.filter(
-      (entry: Entry<any>): entry is IOrganizationSubpage =>
+      (entry: Entry<IOrganizationSubpage>): entry is IOrganizationSubpage =>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cd92fc2 and 91a1c65.

📒 Files selected for processing (1)
  • libs/cms/src/lib/search/importers/organizationSubpage.service.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/cms/src/lib/search/importers/organizationSubpage.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 (1)
libs/cms/src/lib/search/importers/organizationSubpage.service.ts (1)

25-27: Verify impact on existing organization pages.

The filtering logic looks correct, but let's verify that:

  1. Regular (non-standalone) organization pages are still being indexed
  2. The change doesn't affect existing search functionality for other page types
✅ Verification successful

The filtering logic is safe and correctly implemented

Based on the verification results:

  1. The default theme is 'default' as seen in organizationPage.model.ts, confirming that regular organization pages will continue to be indexed
  2. The standalone theme check is only present in the organization subpage importer, not affecting other content types
  3. The search functionality is properly isolated in the content search service, with the filtering happening at the data source level

The change correctly excludes only standalone organization subpages from the global search while maintaining all other search functionality intact.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other theme values to ensure we're not affecting other cases
rg -l "theme.*=.*['\"](?!standalone)['\"]" --type=typescript

# Look for test files that might need updating
fd "organizationSubpage.*test" --type=typescript

Length of output: 545


Script:

#!/bin/bash
# Search for theme-related code with proper regex
rg -l "theme.*standalone" --type ts

# Look for organization page related tests with proper file type
fd "organizationSubpage" -e ts

# Search for other usages of organizationPage theme
ast-grep --pattern 'fields.theme'

# Look for existing search functionality tests
fd "search" -e ts -e spec -e test

Length of output: 4229


Script:

#!/bin/bash
# Check the default theme implementation in organization models
cat libs/cms/src/lib/models/organizationPage.model.ts

# Look for search indexing tests
rg -A 5 "describe.*search.*index" --type ts

# Check the content search service implementation
cat libs/api/domains/content-search/src/lib/contentSearch.service.ts

Length of output: 8620

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

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

Project coverage is 36.53%. Comparing base (f9931f3) to head (2008d3c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ib/search/importers/organizationSubpage.service.ts 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16717      +/-   ##
==========================================
- Coverage   36.54%   36.53%   -0.01%     
==========================================
  Files        6890     6890              
  Lines      143639   143640       +1     
  Branches    40925    40926       +1     
==========================================
- Hits        52486    52485       -1     
- Misses      91153    91155       +2     
Flag Coverage Δ
api 3.37% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
api-domains-communications 39.76% <0.00%> (-0.01%) ⬇️
application-system-api 41.11% <0.00%> (-0.01%) ⬇️
application-template-api-modules 27.69% <0.00%> (-0.01%) ⬇️
cms 0.42% <0.00%> (-0.01%) ⬇️
cms-translations 38.89% <0.00%> (-0.01%) ⬇️
judicial-system-api 19.57% <ø> (ø)
judicial-system-backend 55.17% <0.00%> (-0.01%) ⬇️
services-auth-admin-api 52.47% <ø> (ø)
services-auth-delegation-api 58.20% <ø> (-0.07%) ⬇️
services-auth-ids-api 52.06% <ø> (-0.01%) ⬇️
services-auth-personal-representative 45.54% <ø> (-0.03%) ⬇️
services-auth-personal-representative-public 41.78% <ø> (ø)
services-auth-public-api 49.58% <ø> (ø)
services-user-notification 46.84% <0.00%> (-0.01%) ⬇️
services-user-profile 61.74% <ø> (-0.10%) ⬇️

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

Files with missing lines Coverage Δ
...ib/search/importers/organizationSubpage.service.ts 16.66% <0.00%> (-0.48%) ⬇️

... and 1 file with indirect coverage changes


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 f9931f3...2008d3c. Read the comment docs.

@datadog-island-is
Copy link

Datadog Report

All test runs 275a62d 🔗

10 Total Test Services: 0 Failed, 9 Passed
➡️ Test Sessions change in coverage: 27 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.62s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 12.49s 1 no change Link
api-domains-communications 0 0 0 5 0 28.79s 1 no change Link
api-domains-license-service 0 0 0 0 0 609.54ms 1 no change Link
application-system-api 0 0 0 120 2 3m 46.94s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 11.99s 1 no change Link
cms-translations 0 0 0 3 0 28.18s 1 no change Link
judicial-system-api 0 0 0 59 0 6.11s 1 no change Link
judicial-system-backend 0 0 0 20914 0 20m 48.71s 1 no change Link
services-user-notification 0 0 0 51 0 1m 29.96s 1 no change Link

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