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(services-endorsement-system): Disable caching #16223

Merged
merged 7 commits into from
Oct 3, 2024

Conversation

rafnarnason
Copy link
Member

@rafnarnason rafnarnason commented Oct 1, 2024

caching in frontend is causing suboptimal UX - removing caching

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

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

    • Introduced new mutations for managing endorsement lists: close, open, lock, and unlock.
    • Added a method for creating new endorsement lists.
  • Improvements

    • Enhanced clarity and organization of GraphQL queries and mutations related to endorsements.
    • Updated field exposure in the GraphQL schema for various properties across endorsement models.
  • Bug Fixes

    • Removed caching-specific decorators to streamline GraphQL field definitions.

Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

Walkthrough

The changes involve the modification of GraphQL decorators in various classes related to endorsements within the endorsement system. Specifically, the @CacheField decorator has been replaced with the @Field decorator for several properties in multiple files, impacting how these properties are exposed in the GraphQL schema. Additionally, new methods have been introduced in the resolver to manage endorsement lists, and existing queries have been restructured for clarity.

Changes

File Change Summary
libs/api/domains/endorsement-system/src/lib/dto/paginatedEndorsement.response.ts
libs/api/domains/endorsement-system/src/lib/dto/paginatedEndorsementList.response.ts
Replaced @CacheField with @Field for data and pageInfo properties in both classes.
libs/api/domains/endorsement-system/src/lib/endorsementSystem.resolver.ts Introduced new mutations for managing endorsement lists and restructured existing queries with comments.
libs/api/domains/endorsement-system/src/lib/models/endorsement.model.ts
libs/api/domains/endorsement-system/src/lib/models/endorsementList.model.ts
libs/api/domains/endorsement-system/src/lib/models/endorsementListOpen.model.ts
Replaced @CacheField with @Field for properties like endorsementList, meta, tags, etc.

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • kksteini

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.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 1, 2024

Datadog Report

Branch report: endorsement-system/undo-caching-fix
Commit report: baab0a8
Test service: api

✅ 0 Failed, 4 Passed, 0 Skipped, 3.09s Total Time
➡️ Test Sessions change in coverage: 1 no change

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.86%. Comparing base (e8844cb) to head (9e37d6e).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16223      +/-   ##
==========================================
- Coverage   36.92%   36.86%   -0.06%     
==========================================
  Files        6781     6787       +6     
  Lines      140009   139895     -114     
  Branches    39810    39788      -22     
==========================================
- Hits        51703    51579     -124     
- Misses      88306    88316      +10     
Flag Coverage Δ
api 3.37% <ø> (ø)
application-system-api 41.63% <ø> (ø)
application-template-api-modules 24.38% <ø> (-0.02%) ⬇️
application-ui-shell 21.29% <ø> (ø)

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

see 42 files 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 e8844cb...9e37d6e. Read the comment docs.

@rafnarnason rafnarnason marked this pull request as ready for review October 1, 2024 14:19
@rafnarnason rafnarnason requested a review from a team as a code owner October 1, 2024 14:19
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 (4)
libs/api/domains/endorsement-system/src/lib/dto/paginatedEndorsement.response.ts (1)

11-12: Approved: Caching consistently removed

The change from @CacheField to @Field for the pageInfo property is consistent with the previous modification and further supports the PR objective of disabling caching. This change maintains the GraphQL schema definition while removing caching behavior.

While removing caching aligns with the current objectives, consider monitoring the performance impact of this change. If you notice increased load times or server stress, you might want to explore alternative caching strategies or implement client-side caching mechanisms in the future to balance responsiveness and data freshness.

libs/api/domains/endorsement-system/src/lib/dto/paginatedEndorsementList.response.ts (1)

Line range hint 1-14: Summary: Caching disabled as intended, consider performance implications

The changes in this file successfully remove caching from the PaginatedEndorsementListResponse class by replacing @CacheField with @Field decorators. This aligns with the PR objective of disabling caching to improve user experience.

Key points:

  1. The code maintains type safety and GraphQL compatibility.
  2. It adheres to the coding guidelines for files in the libs directory.
  3. The changes may impact query performance, especially for large datasets.

To ensure a smooth transition:

  1. Implement comprehensive performance monitoring for affected queries.
  2. Consider adding caching at a different layer (e.g., API gateway or CDN) if performance degradation is observed.
  3. Update any documentation or comments that may reference the now-removed caching behavior.
libs/api/domains/endorsement-system/src/lib/models/endorsementList.model.ts (1)

25-29: Consider monitoring performance impact of disabled caching

The removal of caching for both tags and meta properties aligns well with the PR objective of improving user experience by ensuring up-to-date data. This change should resolve issues related to stale data in the frontend. However, it's important to monitor the performance impact of this change, as it may lead to increased data fetching.

Suggestions:

  1. Implement performance monitoring to track any changes in response times or server load.
  2. Consider implementing a more granular caching strategy in the future if performance issues arise, such as time-based cache invalidation or selective caching based on data volatility.

These changes adhere to the coding guidelines for the libs directory, maintaining reusability and proper TypeScript usage.

libs/api/domains/endorsement-system/src/lib/endorsementSystem.resolver.ts (1)

Line range hint 47-239: Monitor performance impact after removing cache control annotations

The removal of cache control annotations from the resolver methods may lead to increased load on backend services due to more frequent client requests. Please monitor the system's performance to ensure it meets user experience expectations, and consider implementing alternative caching strategies if necessary.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9ef986b and ee56b30.

📒 Files selected for processing (6)
  • libs/api/domains/endorsement-system/src/lib/dto/paginatedEndorsement.response.ts (1 hunks)
  • libs/api/domains/endorsement-system/src/lib/dto/paginatedEndorsementList.response.ts (1 hunks)
  • libs/api/domains/endorsement-system/src/lib/endorsementSystem.resolver.ts (16 hunks)
  • libs/api/domains/endorsement-system/src/lib/models/endorsement.model.ts (1 hunks)
  • libs/api/domains/endorsement-system/src/lib/models/endorsementList.model.ts (1 hunks)
  • libs/api/domains/endorsement-system/src/lib/models/endorsementListOpen.model.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
libs/api/domains/endorsement-system/src/lib/dto/paginatedEndorsement.response.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/api/domains/endorsement-system/src/lib/dto/paginatedEndorsementList.response.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/api/domains/endorsement-system/src/lib/endorsementSystem.resolver.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/api/domains/endorsement-system/src/lib/models/endorsement.model.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/api/domains/endorsement-system/src/lib/models/endorsementList.model.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/api/domains/endorsement-system/src/lib/models/endorsementListOpen.model.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 (10)
libs/api/domains/endorsement-system/src/lib/dto/paginatedEndorsement.response.ts (2)

Line range hint 1-14: Summary: Caching successfully disabled for PaginatedEndorsementResponse

The changes in this file consistently remove caching from the PaginatedEndorsementResponse class by replacing @CacheField with @Field decorators. These modifications align well with the PR objective of disabling caching to improve user experience.

Key points:

  1. The code maintains type safety and proper GraphQL schema definitions.
  2. The changes adhere to the coding guidelines for files in the libs directory.
  3. The modifications preserve the reusability of the component across different NextJS apps.

To ensure the impact of these changes is fully understood, please run the following script to check for any GraphQL schema changes:

#!/bin/bash
# Description: Check for GraphQL schema changes related to PaginatedEndorsementResponse

# Test: Search for PaginatedEndorsementResponse in GraphQL schema files
rg --type graphql 'PaginatedEndorsementResponse' libs/api/domains/endorsement-system

This will help verify if there are any unexpected changes to the GraphQL schema as a result of removing caching.


9-10: Approved: Caching removed as intended

The change from @CacheField to @Field for the data property aligns with the PR objective of disabling caching. This modification maintains the GraphQL schema definition while removing the caching behavior, which should contribute to improving the user experience as intended.

To ensure this change is consistent across the codebase, please run the following script:

This will help verify that caching has been consistently disabled throughout the endorsement system.

libs/api/domains/endorsement-system/src/lib/dto/paginatedEndorsementList.response.ts (2)

9-9: LGTM. Consider monitoring query performance.

The change from @CacheField to @Field aligns with the PR objective of disabling caching. This modification maintains the correct type definition for GraphQL while removing the caching behavior.

To ensure this change doesn't negatively impact performance, consider monitoring query response times. You may want to run the following command to check for other instances of @CacheField that might need similar updates:

#!/bin/bash
# Search for remaining @CacheField decorators
rg --type typescript '@CacheField' libs/

11-11: LGTM. Ensure comprehensive testing of pagination.

The change from @CacheField to @Field for the pageInfo property is consistent with the previous modification and aligns with the PR objective of disabling caching.

To ensure this change doesn't introduce any regression in pagination functionality, consider running the following command to identify and review pagination-related tests:

Additionally, manually verify that pagination still works correctly in the UI, especially for large datasets where the impact of removing caching might be more noticeable.

✅ Verification successful

Pagination-related tests verified.

The change from @CacheField to @Field has been validated against existing pagination-related tests.

  • apps/services/sessions/src/app/sessions/sessions.controller.spec.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for pagination-related tests
rg --type typescript 'describe.*pagination|test.*pagination' libs/ src/

Length of output: 169


Script:

#!/bin/bash
# Search for pagination-related tests in TypeScript files
rg -g "*.ts" -g "*.tsx" 'describe.*pagination|test.*pagination' libs/ src/

Length of output: 121


Script:

#!/bin/bash
# Search for pagination-related tests in TypeScript files across the entire repository
rg -g "*.ts" -g "*.tsx" 'describe.*pagination|test.*pagination'

Length of output: 190

libs/api/domains/endorsement-system/src/lib/models/endorsement.model.ts (2)

19-20: LGTM! Verify GraphQL schema impact.

The replacement of @CacheField with @Field for the meta property is consistent with the PR objective of disabling caching. The TypeScript usage is maintained, preserving the non-nullable nature of the property.

To ensure the change doesn't unexpectedly alter the GraphQL schema, please run the following script to compare the old and new schemas:

#!/bin/bash
# Description: Compare old and new GraphQL schemas
# Note: Adjust the paths if necessary

# Generate the new schema
npm run generate-schema > new_schema.graphql

# Compare with the old schema (assuming it's stored in a file called old_schema.graphql)
diff old_schema.graphql new_schema.graphql

16-17: LGTM! Verify frontend compatibility.

The replacement of @CacheField with @Field aligns with the PR objective of disabling caching. The TypeScript usage is maintained, and the nullable: true option is correctly applied for the optional property.

Please ensure that the frontend is updated to handle potentially null endorsementList values. Run the following script to check for frontend usage:

libs/api/domains/endorsement-system/src/lib/models/endorsementListOpen.model.ts (1)

15-16: LGTM! Caching disabled as intended.

The change from @CacheField to @Field aligns with the PR objective of disabling caching to improve user experience. The TypeScript usage and class structure adhere to the coding guidelines for libs directory.

To ensure this change doesn't introduce any unintended consequences, please run the following script to check for any remaining @CacheField usage in the endorsement system:

Also, consider verifying the impact of this change on the frontend, especially regarding data fetching and display performance.

libs/api/domains/endorsement-system/src/lib/models/endorsementList.model.ts (2)

25-26: Approved: Caching removed from tags property

The replacement of @CacheField with @Field(() => [EndorsementListTagsEnum]) aligns with the PR objective of disabling caching. This change should improve the responsiveness of the application by ensuring that the latest tag data is always fetched. The use of TypeScript for defining the property type is maintained, adhering to the coding guidelines.


28-29: Approved: Caching removed from meta property

The replacement of @CacheField with @Field(() => graphqlTypeJson) for the meta property is in line with the PR objective of disabling caching. This change ensures that the latest metadata is always retrieved, potentially improving the user experience. The use of graphqlTypeJson allows for flexible JSON structures in the GraphQL schema, which is beneficial for handling diverse metadata.

libs/api/domains/endorsement-system/src/lib/endorsementSystem.resolver.ts (1)

Line range hint 107-129: Verify public access to general petition endpoints

The methods endorsementSystemGetGeneralPetitionLists, endorsementSystemGetGeneralPetitionList, and endorsementSystemGetGeneralPetitionEndorsements are annotated with @BypassAuth(), allowing unauthenticated access. Please confirm that exposing these endpoints publicly is intentional and does not expose sensitive data.

Run the following script to identify all resolver methods with @BypassAuth():

@rafnarnason rafnarnason added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Oct 3, 2024
@kodiakhq kodiakhq bot merged commit 7eb0c62 into main Oct 3, 2024
38 checks passed
@kodiakhq kodiakhq bot deleted the endorsement-system/undo-caching-fix branch October 3, 2024 10:55
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.

3 participants