Skip to content

Conversation

@adityachoudhari26
Copy link
Contributor

@adityachoudhari26 adityachoudhari26 commented Feb 5, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a new DeploymentsCard component with enhanced search functionality and time period selection.
    • Added AggregateCharts and DeploymentTable components for improved visualization of deployment statistics.
    • Implemented a DeploymentRow component to display detailed deployment information within a table format.
    • Added a SkeletonRow component for better loading state representation.
    • Introduced a new DeploymentHistoryGraph component for visualizing deployment success rates.
    • Enhanced user experience with a responsive layout and improved loading indicators.
  • Bug Fixes

    • Removed hardcoded success rate data, ensuring more accurate and flexible reporting.
  • Refactor

    • Modularized the deployment statistics display, enhancing the overall structure and clarity of the user interface.
    • Updated API queries to include additional parameters for improved data retrieval and flexibility.
    • Simplified the DeploymentsPage by removing unnecessary billing information.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces significant updates to the deployment analytics in both frontend and backend components. The Card.tsx file has been refactored to remove the DeploymentHistoryGraph and add new components like AggregateCharts and DeploymentTable, enhancing the display of deployment statistics and user interaction. The API has been updated to include a timezone field in the deploymentStatsRouter, allowing for more flexible data retrieval and aggregation of job metrics. Additionally, a new constant analyticsStatuses has been introduced to support job status validation.

Changes

File(s) Summary
apps/webservice/src/app/[workspaceSlug]/…/deployments/Card.tsx Removed DeploymentHistoryGraph, added AggregateCharts and DeploymentTable components, refactored DeploymentsCard to manage search and time period selection, and updated API query to include new parameters like timezone.
packages/api/src/router/deployment-stats.ts Added timezone field to the input schema of byWorkspaceId, refactored query logic to utilize the schema namespace, implemented asynchronous fetching, and introduced calculations for job duration percentiles and success rates, along with a new history procedure.
packages/validators/src/jobs/index.ts Introduced a new constant analyticsStatuses that includes specific job statuses relevant for analytics calculations.
apps/webservice/src/app/[workspaceSlug]/…/deployments/AggregateCharts.tsx Added AggregateCharts component for displaying aggregated deployment statistics with responsive layout and metrics calculations.
apps/webservice/src/app/[workspaceSlug]/…/deployments/deployment-table/DeploymentRow.tsx Created DeploymentRow component to display detailed deployment information in a table format, utilizing LazyDeploymentHistoryGraph for visualizing deployment history.
apps/webservice/src/app/[workspaceSlug]/…/deployments/deployment-table/DeploymentTable.tsx Introduced DeploymentTable component for rendering deployment statistics in a table, with conditional rendering based on loading state.
apps/webservice/src/app/[workspaceSlug]/…/deployments/deployment-table/SkeletonRow.tsx Added SkeletonRow component for displaying a loading state in the table.
apps/webservice/src/app/[workspaceSlug]/…/deployments/deployment-table/TableHeadCell.tsx Created TableHeadCell component for managing sorting functionality in table headers.
apps/webservice/src/app/[workspaceSlug]/…/deployments/page.tsx Removed billing header and description from DeploymentsPage, simplifying the component's structure while retaining the DeploymentsCard.
packages/validators/package.json Updated package.json to include a new export for the ./deployments path, enhancing the module's public API.
packages/validators/src/deployments/index.ts Added new enumerations StatsColumn and StatsOrder for improved type safety and validation in deployment data handling.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant DC as DeploymentsCard
    participant DS as DeploymentStatistics
    participant API as Backend API

    U->>DC: Load Deployments card
    DC->>DS: Render deployment statistics (using workspaceSlug)
    DS->>API: Request deployment stats (including timezone)
    API-->>DS: Return aggregated deployment stats
Loading
sequenceDiagram
    participant API as DeploymentStatsRouter
    participant SC as Schema Module
    participant DB as Database
    participant AG as Aggregator (Lodash)

    API->>SC: Validate request and timezone input
    API->>DB: Perform asynchronous query for runStats and join tables
    DB-->>API: Return raw deployment run statistics
    API->>AG: Aggregate job status counts using analyticsStatuses
    API-->>Client: Send combined deployment statistics response
Loading

Possibly related PRs

  • fix: Deployment job graph popover #266: The changes in the main PR are related to the introduction of the AggregateCharts component, which is directly connected to the DailyJobsChart component introduced in the retrieved PR, as both components are designed to visualize job statistics and share similar data handling logic.
  • fix: Optimize release list query and use lazy loading for release cells #269: The changes in the main PR, particularly the introduction of the AggregateCharts and DeploymentTable components in Card.tsx, are related to the modifications in the TableCells.tsx file of the retrieved PR, as both involve updates to how deployment data is structured and displayed, specifically regarding job statuses and their rendering logic.

Suggested reviewers

  • jsbroks

Poem

I'm a happy little bunny, hopping in the code,
Changes sprout like carrots on a nourishing node.
History bars dance in the rhythm of data so true,
With stats and schemas, our bouquet grew.
In this garden of code, watch our analytics bloom!
🐇🥕 Happy coding, let joy resume!

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 23a7821 and 12a59b9.

📒 Files selected for processing (1)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentRow.tsx (1 hunks)

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: 1

🧹 Nitpick comments (1)
apps/webservice/src/app/[workspaceSlug]/(app)/deployments/Card.tsx (1)

26-46: Clamp successRate to prevent layout overflow
If the successRate value ends up greater than 100 or negative, the inline CSS may cause unexpected layout or negative sizing. Consider clamping it to the [0, 100] range.

-              style={{ height: `${successRate}%` }}
+              style={{ height: `${Math.max(0, Math.min(successRate ?? 0, 100))}%` }}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f93c340 and 7f226c2.

📒 Files selected for processing (3)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/Card.tsx (5 hunks)
  • packages/api/src/router/deployment-stats.ts (2 hunks)
  • packages/validators/src/jobs/index.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: **Note on Error Handling:** Avoid strict en...

**/*.{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/validators/src/jobs/index.ts
  • packages/api/src/router/deployment-stats.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/Card.tsx
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Typecheck
  • GitHub Check: Lint
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
🔇 Additional comments (5)
apps/webservice/src/app/[workspaceSlug]/(app)/deployments/Card.tsx (1)

56-61: Double-check off-by-one in last 30 days calculation
Your approach of generating 30 dates from subDays(new Date(), 29 - i) should yield exactly 30 entries. Please verify it aligns correctly under all time zone shifts or DST transitions.

packages/api/src/router/deployment-stats.ts (3)

25-25: LGTM for added timezone field
Adding timezone to the input schema is a solid approach for ensuring accurate date/time calculations.


87-88: Question about the 100-deployment limit
Using .limit(100) might omit deployments if a workspace has more than 100. Double-check that truncating the result is acceptable for your analytics needs.


167-172: Validate merging of runStats and statusCounts
Your merging logic looks correct, but consider verifying there’s no mismatch if either query returns a different set of deployments.

packages/validators/src/jobs/index.ts (1)

49-55: Evaluate whether to include additional statuses in analytics
Currently, analyticsStatuses excludes statuses like cancelled or skipped. Confirm that this omission is intentional if you want a complete picture of job outcomes.

Comment on lines 90 to 99
<td className="p-4">
<div className="flex items-center gap-2">
<div className="h-2 w-full rounded-full bg-neutral-800">
<div
className="h-full rounded-full bg-white transition-all"
style={{
width: `${((deployment.totalSuccess / deployment.totalJobs) * 100).toFixed(0)}%`,
}}
/>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Handle division by zero in success rate bar
If deployment.totalJobs is zero, (deployment.totalSuccess / deployment.totalJobs) * 100 will cause an invalid value. Consider adding a fallback to avoid NaN or Infinity.

-                width: `${((deployment.totalSuccess / deployment.totalJobs) * 100).toFixed(0)}%`,
+                width: `${
+                  deployment.totalJobs > 0
+                    ? ((deployment.totalSuccess / deployment.totalJobs) * 100).toFixed(0)
+                    : 0
+                }%`,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<td className="p-4">
<div className="flex items-center gap-2">
<div className="h-2 w-full rounded-full bg-neutral-800">
<div
className="h-full rounded-full bg-white transition-all"
style={{
width: `${((deployment.totalSuccess / deployment.totalJobs) * 100).toFixed(0)}%`,
}}
/>
</div>
<td className="p-4">
<div className="flex items-center gap-2">
<div className="h-2 w-full rounded-full bg-neutral-800">
<div
className="h-full rounded-full bg-white transition-all"
style={{
width: `${
deployment.totalJobs > 0
? ((deployment.totalSuccess / deployment.totalJobs) * 100).toFixed(0)
: 0
}%`,
}}
/>
</div>
</div>
</td>

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: 1

🧹 Nitpick comments (10)
apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/SkeletonRow.tsx (1)

5-40: LGTM! Well-structured skeleton component with nice fading effect.

The component effectively represents the loading state with a consistent table structure and dynamic opacity for visual feedback.

Consider memoizing the component to prevent unnecessary re-renders:

-export const SkeletonRow: React.FC<{ index: number }> = ({ index }) => (
+export const SkeletonRow = React.memo<{ index: number }>(({ index }) => (
   <tr className="border-b">
     {/* ... existing code ... */}
   </tr>
-);
+));
+SkeletonRow.displayName = 'SkeletonRow';
apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/TableHeadCell.tsx (1)

9-51: Enhance accessibility of the sortable header cell.

While the core sorting functionality is well-implemented, the component needs accessibility improvements.

Apply these changes to improve accessibility:

 export const TableHeadCell: React.FC<{
   title: string;
   orderByKey: StatsColumn;
 }> = ({ title, orderByKey }) => {
   const { getParam, setParams } = useQueryParams();
 
   const orderByParam = getParam("order-by");
   const orderParam = getParam("order");
 
   const isActive = orderByParam === orderByKey;
 
   const onOrderByChange = () => {
     if (orderByParam !== orderByKey) {
       setParams({ "order-by": orderByKey, order: StatsOrder.Desc });
       return;
     }
 
     const newOrder =
       orderParam === StatsOrder.Asc ? StatsOrder.Desc : StatsOrder.Asc;
     setParams({ order: newOrder });
   };
 
   return (
-    <div
+    <button
+      type="button"
       className={cn(
         "flex cursor-pointer select-none items-center gap-1 text-nowrap",
         isActive && "font-semibold text-white",
       )}
       onClick={onOrderByChange}
+      aria-sort={
+        !isActive
+          ? undefined
+          : orderParam === StatsOrder.Asc
+          ? "ascending"
+          : "descending"
+      }
     >
       {title}
       {isActive && (
         <IconChevronDown
           className={cn(
             orderParam === StatsOrder.Asc && "rotate-180",
             "h-4 w-4 transition-transform",
           )}
           strokeWidth={1.5}
+          aria-hidden="true"
         />
       )}
-    </div>
+    </button>
   );
 };
apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentHistoryGraph.tsx (2)

7-17: Consider simplifying the opacity calculation.

The opacity calculation can be simplified for better readability.

-        style={{ opacity: 1 * (1 - i / 30) }}
+        style={{ opacity: 1 - i / 30 }}

21-54: Consider enhancing color accessibility.

The red/green color scheme might be problematic for colorblind users. Consider adding aria labels and patterns/textures for better accessibility.

 <div
   key={j}
-  className="relative h-full w-1.5 overflow-hidden rounded-sm"
+  className="relative h-full w-1.5 overflow-hidden rounded-sm"
+  role="progressbar"
+  aria-label={`Success rate: ${successRate ?? 'No data'}%`}
 >
   {successRate == null ? (
     <div className="absolute bottom-0 h-full w-full bg-neutral-700" />
   ) : (
     <>
-      <div className="absolute bottom-0 h-full w-full bg-red-500" />
+      <div className="absolute bottom-0 h-full w-full bg-red-500 [background-image:linear-gradient(45deg,rgba(0,0,0,.1)_25%,transparent_25%,transparent_50%,rgba(0,0,0,.1)_50%,rgba(0,0,0,.1)_75%,transparent_75%,transparent)]" />
       <div
-        className="absolute bottom-0 w-full bg-green-500"
+        className="absolute bottom-0 w-full bg-green-500 [background-image:linear-gradient(-45deg,rgba(255,255,255,.1)_25%,transparent_25%,transparent_50%,rgba(255,255,255,.1)_50%,rgba(255,255,255,.1)_75%,transparent_75%,transparent)]"
         style={{ height: `${successRate}%` }}
       />
     </>
   )}
 </div>
apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentRow.tsx (1)

41-50: Consider memoizing formatted durations.

The prettyMilliseconds calculations could be memoized to prevent unnecessary recalculations on re-renders.

+const formatDuration = (value: number | null) => {
+  if (value == null) return "N/A";
+  return prettyMilliseconds(Math.round(value) * 1000);
+};

 <td className="p-4 ">
-  {deployment.p50 != null
-    ? prettyMilliseconds(Math.round(deployment.p50) * 1000)
-    : "N/A"}
+  {formatDuration(deployment.p50)}
 </td>
 <td className="p-4 ">
-  {deployment.p90 != null
-    ? prettyMilliseconds(Math.round(deployment.p90) * 1000)
-    : "N/A"}
+  {formatDuration(deployment.p90)}
 </td>
apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentTable.tsx (1)

72-81: Consider optimizing list rendering performance.

The list rendering could be optimized by using useMemo for the loading skeleton rows and adding a proper key prop strategy.

+const SKELETON_ROW_COUNT = 3;
+const skeletonRows = Array.from({ length: SKELETON_ROW_COUNT }).map((_, i) => (
+  <SkeletonRow key={`skeleton-${i}`} index={i} />
+));

 <TableBody>
   {!isLoading &&
     data?.map((deployment) => (
       <DeploymentRow key={deployment.id} deployment={deployment} />
     ))}
-  {isLoading &&
-    Array.from({ length: 3 }).map((_, i) => (
-      <SkeletonRow key={i} index={i} />
-    ))}
+  {isLoading && skeletonRows}
 </TableBody>
apps/webservice/src/app/[workspaceSlug]/(app)/deployments/AggregateCharts.tsx (2)

6-6: Remove commented-out import.

The import statement for prettyMilliseconds is duplicated and commented out.

-// import prettyMilliseconds from "pretty-ms";

42-65: Optimize calculations and improve type safety.

The calculations could be optimized by reducing chain operations and improving type safety.

-  const totalJobs = data != null ? _.sumBy(data, (d) => d.totalJobs) : 0;
+  const totalJobs = data?.reduce((sum, d) => sum + d.totalJobs, 0) ?? 0;

   const totalDuration =
-    data != null
-      ? _.chain(data)
-          .filter((d) => isPresent(d.totalDuration))
-          .sumBy((d) => d.totalDuration!)
-          .value()
-      : 0;
+    data?.reduce((sum, d) => sum + (d.totalDuration ?? 0), 0) ?? 0;

   const totalDurationMs = Math.round(totalDuration * 1000);
+  const formatDuration = (ms: number) => prettyMilliseconds(ms, {
+    unitCount: 2,
+    secondsDecimalDigits: 0,
+  });
-  const totalDurationPretty = prettyMilliseconds(totalDurationMs, {
-    unitCount: 2,
-    secondsDecimalDigits: 0,
-  });
+  const totalDurationPretty = formatDuration(totalDurationMs);

-  const totalSuccess = data != null ? _.sumBy(data, (d) => d.totalSuccess) : 0;
+  const totalSuccess = data?.reduce((sum, d) => sum + d.totalSuccess, 0) ?? 0;
   const totalSuccessRate = data != null ? (totalSuccess / totalJobs) * 100 : 0;
   const totalSuccessRatePretty = `${totalSuccessRate.toFixed(2)}%`;
   const averageDurationMs =
     data != null ? Math.round(totalDurationMs / totalJobs) : 0;
-  const averageDurationPretty = prettyMilliseconds(averageDurationMs, {
-    unitCount: 2,
-    secondsDecimalDigits: 0,
-  });
+  const averageDurationPretty = formatDuration(averageDurationMs);
apps/webservice/src/app/[workspaceSlug]/(app)/deployments/Card.tsx (1)

79-85: Enhance search input accessibility.

Consider adding aria-label and role="search" to improve accessibility for screen readers.

 <Input
   placeholder="Search..."
   value={search}
   onChange={(e) => setSearch(e.target.value)}
-  className="w-80 pl-8"
+  className="w-80 pl-8"
+  aria-label="Search deployments"
+  role="search"
 />
packages/api/src/router/deployment-stats.ts (1)

160-227: Consider adding caching for historical data.

The history query performs complex calculations that don't change frequently. Consider implementing caching to improve performance.

Consider implementing Redis caching with a TTL of 1 hour for the historical data, as it's unlikely to change frequently within that timeframe.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7f226c2 and 23a7821.

📒 Files selected for processing (11)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/AggregateCharts.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/Card.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentHistoryGraph.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentRow.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentTable.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/SkeletonRow.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/TableHeadCell.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/page.tsx (1 hunks)
  • packages/api/src/router/deployment-stats.ts (2 hunks)
  • packages/validators/package.json (1 hunks)
  • packages/validators/src/deployments/index.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: **Note on Error Handling:** Avoid strict en...

**/*.{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)/deployments/page.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/SkeletonRow.tsx
  • packages/validators/src/deployments/index.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/AggregateCharts.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/TableHeadCell.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentTable.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentRow.tsx
  • packages/api/src/router/deployment-stats.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentHistoryGraph.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/deployments/Card.tsx
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Typecheck
  • GitHub Check: Lint
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
🔇 Additional comments (8)
packages/validators/src/deployments/index.ts (1)

1-20: LGTM! Well-structured enums and validators.

The enums and Zod validators are well-defined with consistent naming conventions. The column names use kebab-case which is appropriate for URL parameters, and the sort order values follow standard conventions.

apps/webservice/src/app/[workspaceSlug]/(app)/deployments/page.tsx (1)

28-28: LGTM! Clean and focused page structure.

The page component is well-structured, follows Next.js conventions, and correctly handles workspace validation.

apps/webservice/src/app/[workspaceSlug]/(app)/deployments/deployment-table/DeploymentHistoryGraph.tsx (1)

56-66: LGTM! Well-implemented lazy loading.

The use of useInView for lazy loading is a good performance optimization.

apps/webservice/src/app/[workspaceSlug]/(app)/deployments/Card.tsx (2)

21-28: LGTM! Well-structured utility function.

The getStartDate function effectively handles different time periods and provides clear fallback behavior.


47-59: Validate timezone string before using it in API calls.

While using the browser's timezone is convenient, it's good practice to validate the timezone string to ensure it's in a format the backend can process.

packages/api/src/router/deployment-stats.ts (2)

56-82: LGTM! Well-implemented SQL metrics calculations.

The SQL calculations for p50, p90, totalDuration, and successRate are well-structured with proper null handling and type casting.


86-95: LGTM! Comprehensive order by implementation.

The getOrderBy function handles all possible sorting columns with a sensible default.

packages/validators/package.json (1)

51-54: LGTM! Consistent export configuration.

The new deployments export follows the established pattern and properly defines both types and default exports.

Comment on lines 20 to 28
<Link
href={`/${workspaceSlug}/systems/${deployment.systemSlug}/deployments/${deployment.slug}/releases`}
target="_blank"
>
<div className="flex items-center gap-2">{deployment.name}</div>
<div className="text-xs text-muted-foreground">
{deployment.systemName} / {deployment.name}
</div>
</Link>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add security attributes to external link.

When using target="_blank", it's recommended to add rel="noopener noreferrer" to prevent potential security vulnerabilities.

 <Link
   href={`/${workspaceSlug}/systems/${deployment.systemSlug}/deployments/${deployment.slug}/releases`}
   target="_blank"
+  rel="noopener noreferrer"
 >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Link
href={`/${workspaceSlug}/systems/${deployment.systemSlug}/deployments/${deployment.slug}/releases`}
target="_blank"
>
<div className="flex items-center gap-2">{deployment.name}</div>
<div className="text-xs text-muted-foreground">
{deployment.systemName} / {deployment.name}
</div>
</Link>
<Link
href={`/${workspaceSlug}/systems/${deployment.systemSlug}/deployments/${deployment.slug}/releases`}
target="_blank"
rel="noopener noreferrer"
>
<div className="flex items-center gap-2">{deployment.name}</div>
<div className="text-xs text-muted-foreground">
{deployment.systemName} / {deployment.name}
</div>
</Link>

@adityachoudhari26 adityachoudhari26 merged commit 6cac550 into main Feb 6, 2025
4 of 8 checks passed
@adityachoudhari26 adityachoudhari26 deleted the deployment-page-analytics branch February 6, 2025 02:28
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