-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add squashed update after deleting document history #53
Conversation
cb92101
to
c97b1fd
Compare
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.
It looks like the "diff > document_ttl" case is getting pretty expensive to handle now, so we'll definitely want to run this in a separate asyncio task like @ellisonbg suggested. We'd bind this to an instance attribute, and on every document write, we cancel any existing task and create a new task that sleeps for document_ttl
and then runs this squash logic.
But, this can be done in a follow-up PR.
async with aiosqlite.connect(ystore.db_path) as db: | ||
assert (await (await db.execute("SELECT count(*) FROM yupdates")).fetchone())[ | ||
0 | ||
] == i + 1 | ||
|
||
# assert that adding a record after document TTL deletes previous document history |
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.
# assert that adding a record after document TTL deletes previous document history | |
# assert that adding a record after document TTL squashes previous document history |
await db.execute("DELETE FROM yupdates WHERE path = ?", (self.path,)) | ||
# insert squashed updates | ||
squashed_update = Y.encode_state_as_update(ydoc) | ||
metadata = await self.get_metadata() |
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.
Can we lift this definition out of the if
block so it's not evaluated again on line 256?
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 don't think so, as the metadata can depend on time, for instance.
See #50 (comment).