fix: correct disabled stats metric displaying valid count instead of …#2796
fix: correct disabled stats metric displaying valid count instead of …#2796ogzhanolguncu merged 2 commits intomainfrom
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughThe pull request introduces modifications to the Changes
Suggested labels
Suggested reviewers
Possibly related PRs
Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx (1)
Line range hint
212-241: Consider performance optimizations for role tree construction.The role tree construction logic is correct but could benefit from performance optimizations:
- Consider memoizing the nested permissions structure to prevent unnecessary recalculations on re-renders
- The deeply nested loops for permission path processing could be optimized for large permission sets
Here's a suggested optimization using memoization:
+ import { useMemo } from 'react'; const roleTee = key.workspace.roles.map((role) => { + const buildNestedPermissions = useMemo(() => { const nested: NestedPermissions = {}; for (const permission of key.workspace.permissions) { let n = nested; const parts = permission.name.split("."); for (let i = 0; i < parts.length; i++) { const p = parts[i]; if (!(p in n)) { n[p] = { id: permission.id, name: permission.name, description: permission.description, checked: role.permissions.some((p) => p.permissionId === permission.id), part: p, permissions: {}, path: parts.slice(0, i).join("."), }; } n = n[p].permissions; } } return nested; + }, [key.workspace.permissions, role.permissions]); return { id: role.id, name: role.name, description: role.description, keyId: key.id, active: key.roles.some((keyRole) => keyRole.roleId === role.id), - nestedPermissions: nested, + nestedPermissions: buildNestedPermissions, }; });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (17)
- GitHub Check: Test Packages / Test ./packages/rbac
- GitHub Check: Test Packages / Test ./packages/nextjs
- GitHub Check: Test Packages / Test ./packages/hono
- GitHub Check: Test Packages / Test ./packages/cache
- GitHub Check: Test Packages / Test ./packages/api
- GitHub Check: Test Packages / Test ./internal/clickhouse
- GitHub Check: Test Packages / Test ./internal/resend
- GitHub Check: Test Packages / Test ./internal/keys
- GitHub Check: Test Packages / Test ./internal/id
- GitHub Check: Test Packages / Test ./internal/hash
- GitHub Check: Test Packages / Test ./internal/encryption
- GitHub Check: Test API / API Test Local
- GitHub Check: Test Packages / Test ./internal/billing
- GitHub Check: Test Agent Local / test_agent_local
- GitHub Check: Build / Build
- GitHub Check: autofix
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx (1)
332-332: LGTM! Correct fix for disabled stats display.The metric now correctly displays the count of disabled verifications using
stats.disabledinstead ofstats.valid.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/dashboard/components/dashboard/charts.tsx (2)
139-141: LGTM! Consider extracting the unit as a prop.The addition of the 'ms' unit improves clarity. However, to make the component more reusable, consider making the unit configurable through props.
export const LineChart: React.FC<{ data: { category: string; x: string; y: number; }[]; + unit?: string; }> = ({ data }) => { // ... tooltip={{ formatter: (datum) => ({ name: datum.category, value: `${Intl.NumberFormat(undefined, { notation: "compact", - }).format(Number(datum.y))} ms`, + }).format(Number(datum.y))}${unit ? ` ${unit}` : ''}`, }), }}
208-254: LGTM! Consider extracting date formatting logic to a shared utility.The date formatting implementation is robust with proper error handling and granularity support. However, there are opportunities for improvement:
- This formatting logic could be useful in other components. Consider moving it to a shared utility file.
- Some date format options are repeated across cases. Consider creating shared format configurations.
Example refactor:
// utils/dateFormatting.ts const SHARED_DATE_FORMAT = { month: "short", day: "numeric", year: "numeric", } as const; export const formatDateByGranularity = ( date: string, granularity?: "minute" | "hour" | "day" | "month" ) => { const d = new Date(date); if (Number.isNaN(d.getTime())) { return date; } const formats: Record<string, Intl.DateTimeFormatOptions> = { minute: { ...SHARED_DATE_FORMAT, hour: "numeric", minute: "2-digit", hour12: true, }, hour: { ...SHARED_DATE_FORMAT, hour: "numeric", hour12: true, }, // ... other cases }; return d.toLocaleString(undefined, formats[granularity] ?? formats.minute); };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx(4 hunks)apps/dashboard/components/dashboard/charts.tsx(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx
⏰ Context from checks skipped due to timeout of 90000ms (17)
- GitHub Check: Test Packages / Test ./packages/rbac
- GitHub Check: Test Packages / Test ./packages/nextjs
- GitHub Check: Test Packages / Test ./packages/hono
- GitHub Check: Test Packages / Test ./packages/cache
- GitHub Check: Test Packages / Test ./packages/api
- GitHub Check: Test Packages / Test ./internal/clickhouse
- GitHub Check: Test Packages / Test ./internal/resend
- GitHub Check: Test Packages / Test ./internal/keys
- GitHub Check: Test Packages / Test ./internal/id
- GitHub Check: Test Packages / Test ./internal/hash
- GitHub Check: Test Packages / Test ./internal/encryption
- GitHub Check: Test Agent Local / test_agent_local
- GitHub Check: Test Packages / Test ./internal/billing
- GitHub Check: Build / Build
- GitHub Check: Test API / API Test Local
- GitHub Check: autofix
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
apps/dashboard/components/dashboard/charts.tsx (2)
11-14: LGTM! Improved type definition readability.The multi-line format enhances code readability while maintaining the same type structure.
329-336: LGTM! Enhanced tooltip formatting.The tooltip improvements provide better number formatting with appropriate precision control and compact display. The integration with the new formatDate function ensures consistent date formatting.
…disabled
What does this PR do?
Fixes # (issue)
If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists
Type of change
How should this be tested?
Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated
Summary by CodeRabbit
Bug Fixes
New Features
Refactor