Skip to content

fix: add InsightsRoutingService and refactor InsightsBookingRepository#22057

Merged
eunjae-lee merged 7 commits intomainfrom
chore/refactor-insights-booking-repository
Jun 27, 2025
Merged

fix: add InsightsRoutingService and refactor InsightsBookingRepository#22057
eunjae-lee merged 7 commits intomainfrom
chore/refactor-insights-booking-repository

Conversation

@eunjae-lee
Copy link
Copy Markdown
Contributor

@eunjae-lee eunjae-lee commented Jun 26, 2025

What does this PR do?

This PR does 2 things:

  1. It adds InsightsRoutingService

  2. It converts InsightsBookingRepository to InsightsBookingService as it mostly contains business logic. All the repository-like code has been moved to corresponding repositories.

And so far, we don't have any specific repository-like code for Insights Booking, so we're not having InsightsBookingRepository yet. We might add it in the future.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A - I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Passes integration tests

@vercel
Copy link
Copy Markdown

vercel bot commented Jun 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2025 1:00pm
cal-eu ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2025 1:00pm

@keithwillcode keithwillcode added consumer core area: core, team members only labels Jun 26, 2025
@delve-auditor
Copy link
Copy Markdown

delve-auditor bot commented Jun 26, 2025

No security or compliance issues detected. Reviewed everything up to e81c738.

Security Overview
  • 🔎 Scanned files: 9 changed file(s)
Detected Code Changes
Change Type Relevant files
Enhancement ► repository/membership.ts
    Update findFirst to findUnique method
    Add findAllByTeamIds method
► repository/team.ts
    Add findAllByParentId method
    Add findByIdAndParentId method
► service/insightsBooking.ts
    Move repository to service
    Add service implementation
► service/insightsRouting.ts
    Add service implementation
Refactor ► getAttributesForTeam.handler.ts
    Update to use new findUnique method
Other ► service/tests/insightsBooking.integration-test.ts
    Move and update test file
► service/tests/insightsRouting.integration-test.ts
    Add new test file

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@eunjae-lee eunjae-lee marked this pull request as ready for review June 26, 2025 12:15
@graphite-app graphite-app bot requested a review from a team June 26, 2025 12:15
@dosubot dosubot bot added insights area: insights, analytics 💻 refactor labels Jun 26, 2025
@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Jun 26, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (06/26/25)

1 reviewer was added to this PR based on Keith Williams's automation.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic found 2 issues across 7 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.


export const get = async ({ ctx, input }: GetDataOptions) => {
const teamMembership = await MembershipRepository.findFirstByUserIdAndTeamId({
const teamMembership = await MembershipRepository.findUniqueByUserIdAndTeamId({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method findUniqueByUserIdAndTeamId may not be present in MembershipRepository or may not be implemented as expected. Ensure that this method exists and is correctly implemented, as a typo or missing method could cause runtime errors.

updater: BulkAttributeAssigner;
}) => {
const membership = await MembershipRepository.findFirstByUserIdAndTeamId({ userId, teamId: orgId });
const membership = await MembershipRepository.findUniqueByUserIdAndTeamId({ userId, teamId: orgId });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

findUniqueByUserIdAndTeamId may return all columns for the membership entity. For performance and security, use a select clause to fetch only the required fields (e.g., id).

@eunjae-lee eunjae-lee changed the title refactor: convert InsightsBookingRepository to service fix: add InsightsRoutingService Jun 26, 2025
@eunjae-lee eunjae-lee changed the title fix: add InsightsRoutingService fix: add InsightsRoutingService and refactor InsightsBookingRepository Jun 26, 2025
@github-actions
Copy link
Copy Markdown
Contributor

E2E results are ready!

@eunjae-lee eunjae-lee requested a review from hbjORbj June 26, 2025 14:40
Copy link
Copy Markdown
Contributor

@hbjORbj hbjORbj left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@eunjae-lee eunjae-lee merged commit 0a3b3a6 into main Jun 27, 2025
41 checks passed
@eunjae-lee eunjae-lee deleted the chore/refactor-insights-booking-repository branch June 27, 2025 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer core area: core, team members only insights area: insights, analytics ready-for-e2e 💻 refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants