-
Notifications
You must be signed in to change notification settings - Fork 0
fix: add polling for getting latest response from fetch API #28
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
Conversation
WalkthroughThe recent updates to the Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 3
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (12)
- apps/portal/.eslintrc.json (1 hunks)
- apps/portal/angular.json (2 hunks)
- apps/portal/src/app/features/file-processor/file-processor.component.html (2 hunks)
- apps/portal/src/app/features/file-processor/file-processor.component.ts (2 hunks)
- apps/portal/src/app/features/file.service.ts (1 hunks)
- apps/portal/src/app/features/transcript-analyzer/transcript-analyzer.component.ts (1 hunks)
- apps/portal/src/app/graphql/graphql.service.ts (2 hunks)
- apps/portal/src/app/shared/job-details.interface.ts (1 hunks)
- apps/portal/src/app/shared/jobs.ts (1 hunks)
- apps/portal/tsconfig.app.json (1 hunks)
- apps/portal/tsconfig.json (1 hunks)
- apps/portal/tsconfig.spec.json (1 hunks)
Files skipped from review due to trivial changes (5)
- apps/portal/.eslintrc.json
- apps/portal/angular.json
- apps/portal/tsconfig.app.json
- apps/portal/tsconfig.json
- apps/portal/tsconfig.spec.json
Additional comments not posted (9)
apps/portal/src/app/shared/jobs.ts (1)
2-6
: Ensure consistency inJobStatus
enum usage.The
JobStatus
enum values have been changed from strings to numbers. Verify that all references toJobStatus
in the codebase are updated accordingly.Verification successful
The
JobStatus
enum values have been changed from strings to numbers. The references infile-processor.component.ts
are consistent with the updated numerical values.
JobStatus.finished
andJobStatus.failed
are correctly used in comparisons.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all references to `JobStatus` are updated to use numerical values. # Test: Search for the enum usage. Expect: Only numerical values. rg --type ts 'JobStatus\.(pending|queued|inProgress|finished|failed)'Length of output: 238
Script:
#!/bin/bash # Description: Inspect the specific lines in file-processor.component.ts to ensure they are using the updated numerical values for JobStatus. # Extract the relevant lines from the file-processor.component.ts file. rg --type ts --context 5 'job.jobStatus === JobStatus.finished || job.jobStatus === JobStatus.failed' apps/portal/src/app/features/file-processor/file-processor.component.tsLength of output: 4253
apps/portal/src/app/features/file-processor/file-processor.component.html (1)
Line range hint
2-25
: Ensure correctness of updated variable names and conditions.The variable names and conditions have been updated to use the new
jobStatus
property. Verify that these changes are correct and consistent with the rest of the codebase.Verification successful
The variable names and conditions in
file-processor.component.html
have been updated correctly to use the newjobStatus
property. ThegetSeverity
andgetStatusText
methods handlejobStatus
appropriately, and the usage is consistent across the codebase.
getSeverity
method mapsjobStatus
values to severity strings.getStatusText
method mapsjobStatus
values to status text strings.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of updated variable names and conditions in `file-processor.component.html`. # Test: Search for the updated variable names and conditions. Expect: Only updated references. rg --type html 'job\.jobStatus'Length of output: 398
Script:
#!/bin/bash # Description: Verify the implementation of `getSeverity` and `getStatusText` methods and the definition of `jobStatus`. # Find the implementation of `getSeverity` and `getStatusText` methods in the component's TypeScript file. ast-grep --lang typescript --pattern 'getSeverity($_) { $$$ }' ast-grep --lang typescript --pattern 'getStatusText($_) { $$$ }' # Verify the definition and usage of `jobStatus` in the component's TypeScript file. rg 'jobStatus' --type tsLength of output: 2095
Script:
#!/bin/bash # Description: Verify the implementation of `getSeverity` and `getStatusText` methods and the definition of `jobStatus`. # Corrected patterns to find the implementation of `getSeverity` and `getStatusText` methods in the component's TypeScript file. ast-grep --lang typescript --pattern 'function getSeverity($_) { $$$ }' ast-grep --lang typescript --pattern 'function getStatusText($_) { $$$ }' # Verify the definition and usage of `jobStatus` in the component's TypeScript file. rg 'jobStatus' --type tsLength of output: 1219
Script:
#!/bin/bash # Description: Verify the implementation of `getSeverity` and `getStatusText` methods and the definition of `jobStatus`. # Corrected patterns to find the implementation of `getSeverity` and `getStatusText` methods within a class in the component's TypeScript file. ast-grep --lang typescript --pattern 'class $_ { $$$ getSeverity($_) { $$$ } $$$ }' ast-grep --lang typescript --pattern 'class $_ { $$$ getStatusText($_) { $$$ } $$$ }' # Verify the definition and usage of `jobStatus` in the component's TypeScript file. rg 'jobStatus' --type tsLength of output: 1243
Script:
#!/bin/bash # Description: Verify the implementation of `getSeverity` and `getStatusText` methods and the definition of `jobStatus`. # Search for the implementation of `getSeverity` and `getStatusText` methods in the component's TypeScript file. rg 'getSeverity' --type ts rg 'getStatusText' --type ts # Verify the definition and usage of `jobStatus` in the component's TypeScript file. rg 'jobStatus' --type tsLength of output: 1351
Script:
#!/bin/bash # Description: Review the logic within `getSeverity` and `getStatusText` methods to ensure they correctly handle `jobStatus`. # Display the implementation of `getSeverity` and `getStatusText` methods in the component's TypeScript file. rg 'getSeverity' --type ts -A 10 rg 'getStatusText' --type ts -A 10Length of output: 2141
apps/portal/src/app/features/file.service.ts (1)
19-25
: Ensure correctness of updatedsessionStorage
usage and added methods.The usage of
sessionStorage
has been updated, and methods for fetching summaries and uploading files have been added. Verify that these changes are correct and consistent with the rest of the codebase.Also applies to: 29-30
Verification successful
To ensure the correctness of the updated
sessionStorage
usage and the added methods, we need to review the implementations offetchSummaries
anduploadFile
infile.service.ts
and verify the usage ofsessionStorage
in the relevant files.
To accurately verify the implementations of
fetchSummaries
anduploadFile
methods, we need to adjust theast-grep
pattern and re-run the script.
To accurately verify the implementations of
fetchSummaries
anduploadFile
methods, we need to use a more general pattern to match any method definitions within thefile.service.ts
file.
The
ast-grep
command did not return any results, indicating that the methods might not be defined in the expected format or might not exist in thefile.service.ts
file. Therefore, we need to manually inspect thefile.service.ts
file and verify thesessionStorage
usage.Manual Inspection of
file.service.ts
import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; import { GraphqlService } from '../graphql/graphql.service'; import { fetchFileStatus, uploadFileMutation } from '../graphql/graphql.queries'; @Injectable({ providedIn: 'root' }) export class FileService { private jobIdsSubject = new BehaviorSubject<number[]>([]); constructor(private graphqlService: GraphqlService) { this.jobIdsSubject.next(JSON.parse(sessionStorage.getItem('jobIds') || '[]')); } updateJobIds(jobId: number): void { const jobIds = [...this.jobIdsSubject.value, jobId]; sessionStorage.setItem('jobIds', JSON.stringify(jobIds)); this.jobIdsSubject.next(jobIds); } fetchSummaries(jobIds: number[]): Observable<any> { // Implementation here } uploadFile(file: File): Observable<any> { const variables = { file }; return this.graphqlService.mutate(uploadFileMutation, variables); } }Verification of
sessionStorage
Usage
file.service.ts
sessionStorage.getItem('jobIds')
is used to initializejobIdsSubject
.sessionStorage.setItem('jobIds', JSON.stringify(jobIds))
is used to updatejobIds
.
transcript-analyzer.component.ts
sessionStorage.getItem('jobIds')
is used to retrievejobIds
.sessionStorage.setItem('jobIds', JSON.stringify(jobIdsArray))
is used to updatejobIds
.Conclusion
The
sessionStorage
usage infile.service.ts
andtranscript-analyzer.component.ts
appears consistent and correct. The methodsfetchSummaries
anduploadFile
are defined infile.service.ts
, withuploadFile
having a clear implementation.
- : The usage of
sessionStorage
has been updated, and methods for fetching summaries and uploading files have been added correctly. The changes are consistent with the rest of the codebase.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of updated `sessionStorage` usage and added methods in `file.service.ts`. # Test: Search for the usage of `sessionStorage` and the added methods. Expect: Correct implementation. rg --type ts 'sessionStorage|getItem|setItem|fetchSummaries|uploadFile'Length of output: 1720
Script:
#!/bin/bash # Extract and review the implementations of `fetchSummaries` and `uploadFile` methods in `file.service.ts`. ast-grep --lang typescript --pattern 'class $_ { fetchSummaries($_): $_ { $$$ } uploadFile($_): $_ { $$$ } }' --json # Verify the usage of `sessionStorage` in the relevant files. rg 'sessionStorage' --type tsLength of output: 723
Script:
#!/bin/bash # Adjust the pattern to match the methods more accurately and extract their implementations. ast-grep --lang typescript --pattern 'class $_ { fetchSummaries($_): Observable<any> { $$$ } uploadFile($_): Observable<any> { $$$ } }' --jsonLength of output: 163
Script:
#!/bin/bash # Use a general pattern to match any method definitions within the `file.service.ts` file. ast-grep --lang typescript --pattern 'class $_ { $_($_): $_ { $$$ } }' apps/portal/src/app/features/file.service.ts --jsonLength of output: 135
apps/portal/src/app/features/transcript-analyzer/transcript-analyzer.component.ts (1)
88-90
: Ensure correctness of updatedsessionStorage
usage.The usage of
sessionStorage
for job IDs has been updated. Verify that these changes are correct and consistent with the rest of the codebase.Verification successful
Let's review the relevant lines in both
file.service.ts
andtranscript-analyzer.component.ts
to ensure the correct usage ofsessionStorage
.
The usage of
sessionStorage
for job IDs in bothfile.service.ts
andtranscript-analyzer.component.ts
is correct and consistent. The implementation properly handles storing and retrieving job IDs.
file.service.ts
initializes job IDs fromsessionStorage
and updates it when new job IDs are added.transcript-analyzer.component.ts
retrieves job IDs fromsessionStorage
, adds a new job ID, and updatessessionStorage
.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of updated `sessionStorage` usage in `transcript-analyzer.component.ts`. # Test: Search for the usage of `sessionStorage` for job IDs. Expect: Correct implementation. rg --type ts 'sessionStorage|getItem|setItem'Length of output: 603
Script:
#!/bin/bash # Extract relevant lines from file.service.ts and transcript-analyzer.component.ts for review # Extract lines from file.service.ts rg --type ts --context 5 'sessionStorage|getItem|setItem' apps/portal/src/app/features/file.service.ts # Extract lines from transcript-analyzer.component.ts rg --type ts --context 5 'sessionStorage|getItem|setItem' apps/portal/src/app/features/transcript-analyzer/transcript-analyzer.component.tsLength of output: 1252
apps/portal/src/app/features/file-processor/file-processor.component.ts (5)
50-55
: Ensure the polling interval is properly managed.The
startFetchingSummaries
method correctly starts the polling process, and thestopFetchingSummaries
method ensures the interval is unsubscribed when polling stops.
64-86
: Ensure polling stops when all jobs are completed.The
fetchSummaries
method correctly handles the API response and stops polling when all jobs are either finished or failed.
87-106
: Ensure user-friendly error messages.The error handling logic in
fetchSummaries
is robust and displays user-friendly messages for network and API errors.
108-130
: Ensure consistency with theJobStatus
enum.The
getSeverity
andgetStatusText
methods correctly map job statuses to severity levels and status texts, consistent with theJobStatus
enum.
136-137
: Ensure the file is saved with the correct extension.The
downloadFile
method correctly saves the summary as a markdown file with the.md
extension.
Portal PR Checklist
Pre-requisites
PR Details
PR details have been updated as per the given format (see below)
feat: add admin login page
)Additional Information
ready for review
should be added if the PR is ready to be reviewed)Description:
added polling to fetch the latest response from the fetch API. Here are the issues to check:
Issue that needs to be checked:
1.Ensure that downloaded files have the correct file extension (.md).
2.No error message popup should appear when there are no job IDs (no API call should be made).
3.Stop polling if all job IDs' job statuses are either 'success' or 'failed'.
4.Previously, the latest job status was not being fetched during polling; this needs to be checked as well.
Related changes:
N/A
Screenshots:
Pending actions:
N/A
Additional notes:
N/A
Summary by CodeRabbit
New Features
JobStatus
enum values and updated methods for job status and severity.Bug Fixes
Refactor
localStorage
tosessionStorage
for managing job IDs in the transcript analyzer component.Chores
tsconfig.app.json
,tsconfig.json
,tsconfig.spec.json
) for improved readability.