-
Notifications
You must be signed in to change notification settings - Fork 406
CR-215 workbench local storage history #4120
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
CR-215 workbench local storage history #4120
Conversation
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.
IMO you should not use localStorage to save history of workbench, better to use IndexedDB API. LocalStorage has limited size of memory, also we limit the size of history results (only 20 results per database)
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.
Please, also be sure that users can work with different databases and see results per database
I know that localStorage is limited, but still fas few MB size (about 5). Do you think it is reasonable to expect that 20 commands can exceed that? |
yes, even 1 command result can exceed localStorage size. Users may have several databases, in this case they will have (number of databases * 20) results. Also 1 command can be in group mode and contain several results of commands. |
OK, I will look into it |
Implemented indexedDb storing |
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 think its better to move class IndexedDbStorage to a different file. Also, I would recommend to have a file with instances of different tables (export const wbHistoryStorage = new IndexedDbStorage('RI_WB_HISTORY')
)
IMO it's better to have a separate record for each command execution (like implemented on BE side) than modify each time one.
Will limit of records for 1 database be implemented?
Sure, moving it to separate file makse sense. I don't think we'll have other databases besides wb history one, at least for now. Which is why, I didn't bring external library to manage this.
You mean like, every response from POST /workbench/command-executions to be separate record?
yeah, this is stil Work In Progress |
yes, I think you can try to use indexes https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/index |
added config for max results size and max items in db
@pd-redis What will be if we need to add one more table/storage? I think it will be better to use the library (https://dexie.org/) to be more flexible and stable. |
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.
Please see comments. I think we also need a lot of tests for this, both for the changes to the workbench slice as well as the behavior of services/workbenchStorage.ts
Reg dexie - we discussed it, but the consensus was, that bringing 90K dependency just to store WB history is not worth it. |
…-215-workbench-local-storage-history
@pd-redis will this approach support storing other data in the future? Are we ready to add another collection to idb without migrating existing data? |
In this PR, I am checking if envDependent flag is off, and if it is, do not perform API request to list/get/delete Workbench commands.
Also, if the flag is off, I am storing results of
sendWBCommandAction
andsendWBCommandClusterAction
in localStorage, from where they can be loaded after