Skip to content
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

[IMP] model: create snapshot when loading xlsx file #5320

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from

Conversation

Rachico
Copy link
Contributor

@Rachico Rachico commented Dec 5, 2024

Before this commit, when uploading an XLSX file, the code in the Odoo repository would create a spreadsheet document with data that is encoded in xml. Whenever the file is loaded, we parse the stringified xml to convert it to the o-spreadsheet json structure. The problem is that this conversion can be quite slow and costly when the XLSX file is large.

This commit mitigates the issue by saving a snapshot once the XLSX file is loaded for the first time.

Task: 4080514

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Dec 5, 2024

Pull request status dashboard

src/model.ts Outdated
@@ -281,7 +281,7 @@ export class Model extends EventBus<any> implements CommandDispatcher {

this.joinSession();

if (config.snapshotRequested) {
if (config.snapshotRequested || data["[Content_Types].xml"]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not snapshot if the spreadsheet is in read-only mode (because the user most cannot update the spreadsheet in any way)

@Rachico Rachico force-pushed the 18.0-snapshot-when-open-xlsx-mera branch 2 times, most recently from d4ac9cd to 1bbd91a Compare December 18, 2024 11:58
@@ -366,4 +369,22 @@ describe("Model", () => {
],
});
});

test("snapshot when importing xlsx file", async () => {
jest.spyOn(console, "warn").mockImplementation(() => {});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a global handler to make the tests fail in case of console.error or console.warn

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - exactly :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this global handler, but if I comment this line, the test does not fail. Expected ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird, it was failing before 🤷

if (config.snapshotRequested) {
if (
config.snapshotRequested ||
(data["[Content_Types].xml"] && this.config.mode !== "readonly")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test for the readonly flag

@Rachico Rachico force-pushed the 18.0-snapshot-when-open-xlsx-mera branch from 1bbd91a to 4804a36 Compare December 20, 2024 16:43
Before this commit, when uploading an XLSX file, the code in the
Odoo repository would create a spreadsheet document with data that
is encoded in xml. Whenever the file is loaded, we parse the stringified
xml to convert it to the o-spreadsheet json structure. The problem is
that this conversion can be quite slow and costly when the XLSX file is
large.

This commit mitigates the issue by saving a snapshot once the XLSX file is
loaded for the first time.

Task: 4080514
@Rachico Rachico force-pushed the 18.0-snapshot-when-open-xlsx-mera branch from 4804a36 to adb4f86 Compare December 20, 2024 16:48
@Rachico Rachico requested a review from pro-odoo December 20, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants