-
Notifications
You must be signed in to change notification settings - Fork 54
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
β¨ Link schemas in the repository and continuously update the ERD #941
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git βοΈ
4 Skipped Deployments
|
Updates to Preview Branch (migration-erd) βοΈ
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run βοΈ. |
export const getFileContent = async ( | ||
installationId: number, | ||
owner: string, | ||
repo: string, | ||
path: string, | ||
ref?: string, | ||
): Promise<string> => { | ||
const octokit = await createOctokit(installationId) | ||
|
||
try { | ||
const response = await octokit.repos.getContent({ | ||
owner, | ||
repo, | ||
path, | ||
ref, | ||
}) | ||
|
||
// The GitHub API returns the file content encoded in Base64 | ||
if ('content' in response.data && !Array.isArray(response.data)) { | ||
const content = Buffer.from(response.data.content, 'base64').toString( | ||
'utf-8', | ||
) | ||
return content | ||
} | ||
|
||
throw new Error('Not a file or file content not available') | ||
} catch (error) { | ||
console.error(`Error fetching file content for ${path}:`, error) | ||
throw error | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged the parallel implementations of getRepository that were developed concurrently.
const content = await getFileContent( | ||
Number(repository.installationId), | ||
repository.owner, | ||
repository.name, | ||
`${repository.owner}/${repository.name}`, | ||
file.filename, | ||
prDetails.head.ref, | ||
Number(repository.installationId), | ||
) | ||
|
||
return { | ||
filename: file.filename, | ||
content, | ||
content: content ?? '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a result of merging the parallel implementations of getRepository that were developed concurrently, I also updated the usage accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the implementation in this file, I updated the code to fetch file data from the GitHub API instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation is almost the same as in erdViewer.tsx.
PR Reviewer Guide πHere are some key observations to aid the review process:
|
PR Code Suggestions β¨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ππ»
errorObjects={errorObjects} | ||
/> | ||
</VersionProvider> | ||
{isShowCookieConsent && <CookieConsent />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CookieConsent
should be enabled on all pages, so it should be moved to layout.tsx.
const versionData = { | ||
version: '0.1.0', // NOTE: no maintained version for ERD Web | ||
gitHash: process.env.NEXT_PUBLIC_GIT_HASH, | ||
envName: process.env.NEXT_PUBLIC_ENV_NAME, | ||
date: process.env.NEXT_PUBLIC_RELEASE_DATE, | ||
displayedOn: 'web', | ||
} | ||
const version = v.parse(versionSchema, versionData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to commonize with Liam ERD side.
key={path} | ||
href={path} | ||
className={styles.erdLink} | ||
aria-label={`View ERD diagram for ${filename}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed here, so I removed it π
Issue
Why is this change needed?
2025-03-21.18.28.58.mov
What would you like reviewers to focus on?
Testing Verification
What was done
π€ Generated by PR Agent at 4f12f89
ERDViewer
component for rendering database structures.getFileContent
with a cached version.getRepository
utility for repository metadata retrieval.notFound
calls.Detailed Changes
api.server.ts
Refactor GitHub API utilities with caching
frontend/apps/app/libs/github/api.server.ts
getRepository
and cachedgetFileContent
functions.getFileContent
for better error handling and caching.getFileContent
implementation.processSavePullRequest.ts
Update `processSavePullRequest` to use cached API
frontend/apps/app/src/functions/processSavePullRequest.ts
getFileContent
usage to use the new cached version.getFileContent
calls.MigrationDetailPage.module.css
Add styles for ERD links
frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.module.css
erdViewer.tsx
Add `ERDViewer` component for database visualization
frontend/apps/app/app/(app)/app/projects/[projectId]/erd/[branchOrCommit]/[...slug]/erdViewer.tsx
ERDViewer
component for rendering database structures.ERDRenderer
and cookie consent functionality.page.tsx
Implement ERD page with GitHub integration
frontend/apps/app/app/(app)/app/projects/[projectId]/erd/[branchOrCommit]/[...slug]/page.tsx
MigrationDetailPage.tsx
Add ERD links to migration detail page
frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx
Additional Notes