Skip to content

Conversation

@adityachoudhari26
Copy link
Contributor

@adityachoudhari26 adityachoudhari26 commented Feb 4, 2025

Summary by CodeRabbit

  • New Features

    • Added a clear button for release channel selection, giving users an easy way to reset their choice.
  • Refactor

    • Simplified and consolidated the handling of release channel configurations across the interface for a cleaner, more intuitive experience.
    • Streamlined logic for managing release channels by focusing exclusively on policy identifiers.
  • Chores

    • Updated backend data queries and database schema to support the streamlined release channel management workflow, including the removal of unnecessary relationships and properties.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2025

Walkthrough

The changes refactor the handling of release channels and filters across the codebase. On the front end, components such as the deployment drawer and release channel forms now extract and pass filter values more explicitly, with obsolete UI components removed. The back-end API routes and database schema have been updated to remove direct dependencies on environment release channels in favor of policy-based management. Job dispatch logic and related hooks have been streamlined to use unified release channel data, simplifying query parameters and eliminating redundant logic.

Changes

File(s) Change Summary
apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx
apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx
apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/ReleaseChannels.tsx
apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Usage.tsx
apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/[versionId]/EnvironmentNode.tsx
Refactored release channel extraction and filter handling; updated query parameters; simplified onChange logic with a new Button; removed the legacy ReleaseChannels component; and shifted inline logic into the useReleaseChannel hook.
apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/useOverridePolicy.ts
apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/[versionId]/useReleaseChannel.ts
Streamlined mutation calls and consolidated release channel determination to focus solely on policy release channels.
apps/webservice/src/app/api/v1/environments/[environmentId]/route.ts
apps/webservice/src/app/api/v1/openapi.ts
apps/webservice/src/app/api/v1/systems/[systemId]/environments/[name]/route.ts
Modified environment GET/DELETE queries and OpenAPI schema to remove fetching of releaseChannels, now only returning policy and metadata.
packages/api/src/router/deployment.ts
packages/api/src/router/environment.ts
packages/api/src/router/release.ts
Removed joins and procedures related to environment release channels; updated queries to return data based solely on policy release channel details.
packages/db/drizzle/0067_easy_lady_ursula.sql
packages/db/drizzle/meta/_journal.json
packages/db/src/create-env.ts
packages/db/src/schema/environment-relations.ts
packages/db/src/schema/release-channel-relations.ts
packages/db/src/schema/release-channel.ts
Dropped the environment_release_channel table; added a journal entry; updated schema relations and adjusted the createEnv logic to use policy identifiers instead of environment identifiers for release channel association.
packages/job-dispatch/src/environment-creation.ts
packages/job-dispatch/src/environment-release-channel-update.ts
packages/job-dispatch/src/policies/release-string-check.ts
packages/job-dispatch/src/resource/dispatch-resource.ts
Simplified release channel data access in job dispatch logic; removed redundant functions and type definitions; and refactored logic to exclusively use environmentPolicyReleaseChannels for update and dispatch operations.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant D as Deployment Drawer
    participant H as Release Channel Hook
    participant API as API Endpoint
    participant DB as Database

    U->>D: Interact with deployment UI
    D->>H: Request release channel data
    H->>API: Query policy-based release channel info
    API->>DB: Fetch release channel filter & status
    DB-->>API: Return channel details
    API-->>H: Pass back rcId, filter, and status
    H-->>D: Provide updated channel information
    D->>D: Refresh UI with new release channel state
Loading

Possibly related PRs

Poem

I'm a little rabbit, hopping through the code,
Skipping over tables that no longer need to be towed.
With release channels streamlined and filters set just right,
My whiskers twitch in delight at this refactored night.
Code paths cleared and logic pure, my hops now flow with ease,
Celebrating clean commits with joyful ASCII cheese!
🐇💻 Happy coding!

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96f5ddf and 52ffd50.

📒 Files selected for processing (1)
  • packages/db/drizzle/meta/_journal.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/db/drizzle/meta/_journal.json
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Typecheck
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Lint

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

🧹 Nitpick comments (2)
apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Usage.tsx (1)

52-56: Ternary condition is logically correct.
As a nitpick, you could shorten the condition or use optional chaining if desired. However, the current approach is perfectly fine.

apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/[versionId]/EnvironmentNode.tsx (1)

143-144: LGTM! Consider adding error handling.

The refactoring improves code organization by:

  • Using a dedicated hook for release channel logic
  • Simplifying state management
  • Using clear variable names

Consider adding error handling for potential hook failures.

-  const { isPassingReleaseChannel, releaseChannelId, loading } =
-    useReleaseChannel(deploymentId, environmentId, releaseVersion);
+  const { isPassingReleaseChannel, releaseChannelId, loading, error } =
+    useReleaseChannel(deploymentId, environmentId, releaseVersion);
+
+  if (error) {
+    return (
+      <div className="flex items-center gap-2">
+        <Failing /> Failed to load release channel
+      </div>
+    );
+  }

Also applies to: 149-169

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b59f57 and 96f5ddf.

📒 Files selected for processing (23)
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/ReleaseChannels.tsx (0 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/useOverridePolicy.ts (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx (3 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Usage.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/[versionId]/EnvironmentNode.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/[versionId]/useReleaseChannel.ts (2 hunks)
  • apps/webservice/src/app/api/v1/environments/[environmentId]/route.ts (1 hunks)
  • apps/webservice/src/app/api/v1/openapi.ts (0 hunks)
  • apps/webservice/src/app/api/v1/systems/[systemId]/environments/[name]/route.ts (0 hunks)
  • packages/api/src/router/deployment.ts (0 hunks)
  • packages/api/src/router/environment.ts (0 hunks)
  • packages/api/src/router/release.ts (2 hunks)
  • packages/db/drizzle/0067_easy_lady_ursula.sql (1 hunks)
  • packages/db/drizzle/meta/_journal.json (1 hunks)
  • packages/db/src/create-env.ts (2 hunks)
  • packages/db/src/schema/environment-relations.ts (0 hunks)
  • packages/db/src/schema/release-channel-relations.ts (1 hunks)
  • packages/db/src/schema/release-channel.ts (1 hunks)
  • packages/job-dispatch/src/environment-creation.ts (2 hunks)
  • packages/job-dispatch/src/environment-release-channel-update.ts (2 hunks)
  • packages/job-dispatch/src/policies/release-string-check.ts (3 hunks)
  • packages/job-dispatch/src/resource/dispatch-resource.ts (1 hunks)
💤 Files with no reviewable changes (6)
  • apps/webservice/src/app/api/v1/systems/[systemId]/environments/[name]/route.ts
  • apps/webservice/src/app/api/v1/openapi.ts
  • packages/db/src/schema/environment-relations.ts
  • packages/api/src/router/environment.ts
  • packages/api/src/router/deployment.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/ReleaseChannels.tsx
✅ Files skipped from review due to trivial changes (1)
  • packages/db/drizzle/0067_easy_lady_ursula.sql
🧰 Additional context used
📓 Path-based instructions (15)
apps/webservice/src/app/api/v1/environments/[environmentId]/route.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/useOverridePolicy.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

packages/db/src/schema/release-channel-relations.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

packages/api/src/router/release.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

packages/db/src/create-env.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

packages/job-dispatch/src/environment-creation.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

packages/job-dispatch/src/policies/release-string-check.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

packages/job-dispatch/src/environment-release-channel-update.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

packages/job-dispatch/src/resource/dispatch-resource.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

packages/db/src/schema/release-channel.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/[versionId]/EnvironmentNode.tsx (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/[versionId]/useReleaseChannel.ts (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Usage.tsx (1)

Pattern **/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

📓 Learnings (2)
apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx (1)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-12T09:55:38.456Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Usage.tsx (1)
Learnt from: adityachoudhari26
PR: ctrlplanedev/ctrlplane#188
File: apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx:42-44
Timestamp: 2024-11-12T09:55:38.456Z
Learning: In `apps/webservice/src/app/[workspaceSlug]/_components/release-channel-drawer/Usage.tsx`, within the `Usage` component, the arrays used for filtering inherited environments are expected to remain small. Therefore, performance optimizations for this filtering logic are not necessary.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Typecheck
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Lint
🔇 Additional comments (35)
packages/api/src/router/release.ts (3)

282-282: LGTM!

The formatting adjustment improves code readability while maintaining the same functionality.


302-304: LGTM! Clean refactoring of release channel property extraction.

The changes improve code clarity through:

  1. Direct destructuring of properties
  2. Clean null handling with the nullish coalescing operator
  3. Early return pattern for undefined filters

312-312: LGTM! Simplified release matching condition.

The change aligns with the policy-based release channel management approach, reducing complexity while maintaining functionality.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Usage.tsx (7)

1-2: No concerns found for these imports.


8-8: No concerns found for this import.


10-12: Good use of NonNullable.
This type definition clearly ensures that usage is not null, which enhances type safety.


15-15: Using useQueryParams for parameter management is appropriate here.
No issues found with this approach, and it keeps the component logic straightforward.


17-22: The setEnvironmentIdAndTab function logic looks correct.
This ensures the query parameters are properly set for the environment drawer.


24-29: The setPolicyIdAndTab function logic appears correct.
No issues found with setting the query parameters for the policy drawer.


35-35: Destructuring policies from usage is straightforward and clear.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/useOverridePolicy.ts (3)

5-17: LGTM! Well-structured cache invalidation.

The hook effectively groups related cache invalidations and follows a logical order from specific to general queries.


19-28: LGTM! Clean hook implementation.

The hook follows React patterns well with proper TypeScript types and good separation of concerns.

Also applies to: 33-37


30-31: LGTM! Concise Promise chain implementation.

The simplified Promise chain maintains the same functionality while following the coding guidelines for error handling.

Let's verify how errors are handled up the call chain:

✅ Verification successful

LGTM! The error propagation is intact, and the concise Promise chain in the onUpdate function correctly passes errors up the call chain.

  • Error handling in components (e.g., in apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/DeploymentControl.tsx) demonstrates that errors from onUpdate calls are properly caught.
  • The overall design complies with our coding guidelines with consistent error management across usage sites.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for error handling of onUpdate calls
rg -A 5 "onUpdate\(" apps/webservice/src/app

Length of output: 6600

packages/db/src/schema/release-channel-relations.ts (1)

3-4: LGTM! The relations are correctly defined.

The changes align with the PR objective by removing environment-level release channel relations and maintaining policy-level relations. The remaining relations correctly define:

  1. Many-to-many relationship between release channels and environment policies
  2. One-to-many relationship between environment policies and their release channels

Also applies to: 7-12, 14-26

packages/db/src/schema/release-channel.ts (1)

4-6: LGTM! The schema is correctly defined with proper constraints.

The changes align with the PR objective by:

  1. Removing environment-level release channel configuration
  2. Maintaining policy-level release channel configuration with proper foreign key constraints
  3. Ensuring data integrity through unique indexes on policy-channel and policy-deployment pairs

Also applies to: 8-26, 28-30

packages/db/src/create-env.ts (1)

9-20: LGTM! The release channel creation is correctly updated.

The changes align with the PR objective by:

  1. Shifting release channel configuration from environment to policy level
  2. Correctly handling the creation of policy-level release channels
  3. Maintaining proper data consistency during environment creation

Also applies to: 51-52

packages/job-dispatch/src/environment-creation.ts (1)

33-35: LGTM! The job creation logic is correctly updated.

The changes align with the PR objective by:

  1. Accessing release channels through the policy instead of directly from the environment
  2. Correctly handling policy-level release channels in job creation
  3. Maintaining proper data access patterns

Also applies to: 50-53

apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx (4)

6-6: LGTM!

The Button import is correctly added and aligns with the new Clear button functionality.


41-42: LGTM!

The onChange function has been simplified to directly handle null values, improving code clarity.


77-83: LGTM!

The Clear button is well-implemented with appropriate:

  • Variant styling
  • onClick handler for clearing the selection
  • Disabled state when no release channel is selected

88-93: LGTM!

The ReleaseChannelProps type declaration is well-structured and appropriately placed near its usage.

packages/job-dispatch/src/environment-release-channel-update.ts (2)

191-191: LGTM!

The query has been appropriately simplified to focus on policy ID, aligning with the objective of making release channels policy-specific.


204-205: LGTM!

The environment object destructuring has been appropriately simplified to only extract necessary properties, aligning with the policy-based release channel management.

Also applies to: 209-209

packages/job-dispatch/src/resource/dispatch-resource.ts (1)

66-68: LGTM!

The changes correctly:

  • Simplify environment destructuring
  • Update release channel access to use policy
  • Maintain proper error handling through optional chaining

Also applies to: 70-70, 74-74

packages/db/drizzle/meta/_journal.json (1)

474-480: LGTM!

The new migration entry is correctly formatted and maintains consistency with existing entries.

apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/[versionId]/useReleaseChannel.ts (3)

23-26: LGTM! Clean and concise release channel extraction.

The code effectively extracts the release channel ID and filter from the policy, with proper null handling.


34-38: LGTM! Well-structured filter composition.

The release filter construction using _.compact elegantly handles both version and policy filters.


55-55: LGTM! Enhanced return value.

The addition of releaseChannelId to the return value improves the hook's utility.

apps/webservice/src/app/api/v1/environments/[environmentId]/route.ts (1)

23-23: LGTM! Simplified environment query.

The removal of releaseChannels from the with clause aligns with the architectural shift to policy-based release channel management.

packages/job-dispatch/src/policies/release-string-check.ts (3)

51-64: LGTM! Improved data transformation.

The chain of transformations using lodash is clean and efficient, properly grouping and mapping the data.


79-84: LGTM! Simplified release channel handling.

The code effectively handles the release channel filter with proper null checks.


42-45: Verify the impact of switching to inner join.

The change from left join to inner join with environmentPolicy might exclude environments without policies.

✅ Verification successful

The inner join change is appropriate given current usage.

  • The query now returns only environments that have an associated policy, which matches the downstream logic that immediately dereferences environment_policy without null checks.
  • No evidence was found that environments without policies are valid or required in this context.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for environments that might be affected by the join change
ast-grep --pattern 'schema.environment.find($$$)' | rg -A 5 'where.*policyId.*null'

Length of output: 85


Script:

#!/bin/bash
# Print the context around the inner join in release-string-check.ts to check the usage context
sed -n '40,60p' packages/job-dispatch/src/policies/release-string-check.ts

Length of output: 783


Script:

#!/bin/bash
# Search for the schema definition of "environment" to check if policyId is non-nullable,
# which would justify using an inner join.
rg "environment.*policyId" -n packages/job-dispatch/src/schema*

Length of output: 141

apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/DeploymentResourceDrawer.tsx (2)

49-52: LGTM! Clean release filter extraction.

The destructuring with default empty object pattern effectively handles the case when no matching release channel is found.


80-80: LGTM! Explicit filter handling.

The use of nullish coalescing with undefined ensures proper filter behavior in the query.

apps/webservice/src/app/[workspaceSlug]/(app)/systems/[systemSlug]/deployments/[deploymentSlug]/releases/[versionId]/EnvironmentNode.tsx (1)

32-32: LGTM! Good architectural change.

Moving release channel logic to a dedicated hook improves code organization and maintainability.

@adityachoudhari26 adityachoudhari26 merged commit 9ffa291 into main Feb 4, 2025
10 checks passed
@adityachoudhari26 adityachoudhari26 deleted the remove-env-release-channels branch February 4, 2025 05:34
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.

2 participants