Regularly scrub query history view#1426
Merged
edoardopirovano merged 1 commit intomainfrom Jul 14, 2022
Merged
Conversation
extensions/ql-vscode/src/vscode-tests/no-workspace/query-history.test.ts
Fixed
Show fixed
Hide fixed
5314893 to
338ac41
Compare
338ac41 to
d610c96
Compare
aeisenberg
approved these changes
Jul 14, 2022
Contributor
aeisenberg
left a comment
There was a problem hiding this comment.
This means there is a window of < 2 hours when a query may exist in an open workspace, but have been deleted on disk (only if there are multiple workspaces open at once). I think this is a minor issue and unlikely to happen.
|
|
||
| async removeDeletedQueries() { | ||
| await Promise.all(this.treeDataProvider.allHistory.map(async (item) => { | ||
| if (item.t == 'local' && item.completedQuery && !(await fs.pathExists(item.completedQuery?.query.querySaveDir))) { |
Contributor
There was a problem hiding this comment.
Minor: No need to check if item.completedQuery is truthy if your are using .? later on.
Suggested change
| if (item.t == 'local' && item.completedQuery && !(await fs.pathExists(item.completedQuery?.query.querySaveDir))) { | |
| if (item.t == 'local' && !(await fs.pathExists(item.completedQuery?.query.querySaveDir))) { |
Contributor
Author
There was a problem hiding this comment.
Unfortunately, I don't think that can be omitted. Without it, the compiler will complain that item.completedQuery?.query.querySaveDir is not a valid argument to fs.pathExists because it may be undefined.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR triggers a scrubbing of the history view after we've deleted old queries. I also considered (and, in fact, implemented to try it out) tracking what queries we have deleted the directories of, and only removing those from the query history view. This seems reasonable, since it avoids a few filesystem checks. However, those checks are pretty cheap, and that solution runs into issues if another workspace deletes a query in which case it will stay in our view forever. With my chosen approach, it will at least get deleted within 2-3 hours on all other workspaces when they run a scrub (and immediately on the one that performed the deletion).
A further extension we talked about would be to this would be to wrap all methods that try to access the query directory, and if those find that the file they are looking for no longer exists then trigger this scrubbing method to remove invalid entries from the history and give a friendly message to the user rather than the current file not found error. This would improve the UX when users have multiple workspaces open and try to access a query that has been deleted in another one. That change is quite involved, though, because there's so many different methods that use the query directory, and I can't think of a nice way to catch all these errors at a higher up level either. Thus, I'm not sure if we actually want to do this, since it introduces a fair bit of tech debt for a small UX improvement in a corner case.
Checklist
ready-for-doc-reviewlabel there.