-
Notifications
You must be signed in to change notification settings - Fork 2
refactor(api): optimize api-handlers.ts and client.ts #11
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d3d13f6
chore(coderabbit): add configuration for comprehensive optimization r…
ZeR020 2e56837
refactor(api): centralize safe transforms, optimize tag lookup, fix m…
ZeR020 bd808ea
fix(api): address optimization review findings
ZeR020 3c95d0b
fix(api): preserve string timestamp conversion
ZeR020 39dab05
fix(api): preserve historical timestamp conversion
ZeR020 e9c23da
Merge branch 'main' into refactor/api-handlers-optimization
ZeR020 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json | ||
| language: en-US | ||
| early_access: false | ||
| reviews: | ||
| profile: assertive | ||
| request_changes_workflow: true | ||
| high_level_summary: true | ||
| poem: false | ||
| review_status: true | ||
| collapse_walkthrough: true | ||
| path_filters: | ||
| - "!dist/**" | ||
| - "!node_modules/**" | ||
| - "!graphify-out/**" | ||
| - "!.planning/**" | ||
| - "!bun.lock" | ||
| - "!package-lock.json" | ||
| path_instructions: | ||
| - path: "src/**/*.ts" | ||
| instructions: | | ||
| Perform a deep efficiency and optimization review: | ||
| 1. Identify redundant code, dead code, and over-engineered patterns | ||
| 2. Suggest algorithmic improvements for performance-critical paths | ||
| 3. Flag unnecessary abstractions that add complexity without value | ||
| 4. Recommend modern ES2022+ syntax replacements for legacy patterns | ||
| 5. Identify opportunities for lazy loading and tree-shaking | ||
| 6. Review error handling for missing cases or swallowing | ||
| 7. Check for memory leaks in intervals, timeouts, and event listeners | ||
| 8. Validate that async/await usage is optimal vs Promise chains | ||
| 9. Flag any duplicate logic that should be centralized | ||
| 10. Recommend reducing LOC while preserving readability | ||
| - path: "tests/**/*.ts" | ||
| instructions: | | ||
| Review test suite for efficiency: | ||
| 1. Identify slow or redundant tests | ||
| 2. Check for proper isolation and mock cleanup | ||
| 3. Flag tests that test implementation details instead of behavior | ||
| 4. Suggest parallelization opportunities | ||
| auto_review: | ||
| enabled: true | ||
| ignore_title_keywords: [] | ||
| drafts: true | ||
| base_branches: ["main"] | ||
| tools: | ||
| shellcheck: | ||
| enabled: false | ||
| ruff: | ||
| enabled: false | ||
| markdownlint: | ||
| enabled: true | ||
| github-checks: | ||
| enabled: true | ||
| timeout_ms: 90000 | ||
| chat: | ||
| auto_reply: true | ||
| integrations: | ||
| jira: | ||
| usage: disabled | ||
| linear: | ||
| usage: disabled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /** | ||
| * Shared utility functions for safe data transformations. | ||
| * Centralized to eliminate duplication across client.ts and api-handlers.ts. | ||
| */ | ||
|
|
||
| export function safeToISOString(timestamp: unknown): string { | ||
| try { | ||
| if (timestamp === null || timestamp === undefined) { | ||
| return new Date().toISOString(); | ||
| } | ||
| const numValue = typeof timestamp === "bigint" ? Number(timestamp) : Number(timestamp); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| if (isNaN(numValue) || numValue < 0) { | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| return new Date().toISOString(); | ||
| } | ||
|
|
||
| return new Date(numValue).toISOString(); | ||
| } catch { | ||
| return new Date().toISOString(); | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| export function safeJSONParse(jsonString: unknown): unknown { | ||
| if (!jsonString || typeof jsonString !== "string") { | ||
| return undefined; | ||
| } | ||
| try { | ||
| return JSON.parse(jsonString); | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.