Repository navigation
(old) Remove User File Service Local Cache - #1476
ethanwong16 wants to merge 3 commits into
Conversation
Updated Files: - user-file-service.ts - stub-user-file.service.ts - source-tables.service.ts - user-file-section.component.ts - user-file-upload.service.ts - user-project-section.component.ts - ngbd-modal-add-project-file.component.html - ngbd-modal-add-project-file.component.ts - user-project.service.ts
Yicong-Huang
left a comment
There was a problem hiding this comment.
Left a comment. I want to test this PR however this seems from a forked repo. Can you create the branch in texera/Texera instead?
| private registerUpdateUserFileInFileSourceOp(): void { | ||
| this.userFileService.getUserFilesChangedEvent().subscribe(_ => { | ||
| this.userFileNames = this.userFileService.getUserFiles().map(file => `${file.ownerName}/${file.file.name}`); | ||
|
|
||
| Array.from(this.dynamicSchemaService.getDynamicSchemaMap().keys()).forEach(operatorID => { | ||
| const schema = this.dynamicSchemaService.getDynamicSchema(operatorID); | ||
| // if operator input attributes are in the result, set them in dynamic schema | ||
| const fileSchema = this.changeInputToEnumInJsonSchema( | ||
| schema, | ||
| fileNameInJsonSchema, | ||
| this.userFileNames, | ||
| "File Name" | ||
| ); | ||
| if (!fileSchema) { | ||
| return; | ||
| } | ||
| if (!isEqual(schema, fileSchema)) { | ||
| SchemaPropagationService.resetAttributeOfOperator(this.workflowActionService, operatorID); | ||
| this.dynamicSchemaService.setDynamicSchema(operatorID, fileSchema); | ||
| } | ||
| this.userFileService | ||
| .getUserFilesChangedEvent() | ||
| .pipe( | ||
| concatMap(_ => { | ||
| return this.userFileService.retrieveDashboardUserFileEntryList(); | ||
| }) | ||
| ) | ||
| .subscribe(dashboardFileEntries => { | ||
| this.userFileNames = dashboardFileEntries.map(file => `${file.ownerName}/${file.file.name}`); |
There was a problem hiding this comment.
the source table service updates files whenever the user file changes. however, if user file does not change, how does it initialize the file list?
There was a problem hiding this comment.
The current workaround I have is the updateUserFilesChangedEvent() function I added to the UserFileService. This function can be invoked to let the UserFileService know about a user file change so it can update dashboardUserFileEntryChanged.
In the original UserFileService, it would indicate a user file changed upon a refresh / clear of the files. So I updated the UserFileSection to invoke updateUserFilesChangedEvent() to inform the UserFileService whenever files would be refreshed or cleared.
Would this be a good way to handle the source table service updating files?
Just created the new branch on texera/Texera, should I continue to push any changes to this forked branch or would it be better to reopen the PR on the new branch? |
would be better to reopen with the branch in texera/Texera. thanks! |
|
reopened PR on new branch #1486 |
Introduction
This PR refactors the code in the
UserFileServiceto remove its local cache of DashboardUserFileEntries. It also updates all components depending on or using theUserFileService. The goal is to reduce usage of local caches within the user dashboard as well as simplify reuse of theUserFIleSectionComponentin theUserProjectSectionComponent.Solution
Previously the
UserFileServicemaintained a local cache of DashboardUserFileEntries and required components to invoke a function to continuously refresh this local cache. This also required components to continuously retrieve files from theUserFileServicein case the cache might have changed. As a solution, theUserFIleServiceno longer keeps a local cache of DashboardUserFileEntries and now has a public function to retrieve DashboardUserFileEntries from a backend endpoint.Detailed List of Changes Made
Changes were made only to the frontend.
user-file-service.tsstub-user-file.service.tssource-tables.service.tsuser-file-section.component.tsuser-file-upload.service.tsuser-project-section.component.tsngbd-modal-add-project-file.component.htmlngbd-modal-add-project-file.component.tsuser-project.service.tsFuture TODOs
UserFileServiceto modify / reuseUserFileSectioncomponent withinUserProjectSection