Commit graph

302 commits

Author SHA1 Message Date
Damien Elmes
8cb3ed7435 drop lock() and setAutocommit()
We no longer need to worry about pysqlite implicitly beginning
transactions, and can be more explicit about beginning/ending
transactions

save() now also has a trx argument controlling whether a
transaction should be started / left open
2020-03-20 21:15:23 +10:00
Damien Elmes
3256c74409 pass weakref in from storage to fix type checking/code completion 2020-03-20 21:15:23 +10:00
Damien Elmes
116f7fa3f1 support first_row_only 2020-03-20 21:15:23 +10:00
Damien Elmes
7e5f713f05 proper implementation of executemany(); drop executescript() 2020-03-20 21:15:23 +10:00
Damien Elmes
3f3a45e2ba add Collection struct, and get media check working again
- media check no longer needs collection to be closed
- use savepoints for operations initiated by Rust, so they are
atomic without forcing a commit
2020-03-20 21:15:23 +10:00
Damien Elmes
700d713f80 add begin/commit/rollback, and support creating collections
all but one unit test is now passing
2020-03-20 21:15:23 +10:00
Damien Elmes
0147d9e470 drop log= argument from Collection 2020-03-20 21:15:23 +10:00
Damien Elmes
70c7cde2cd remove remaining db kwargs 2020-03-20 21:15:23 +10:00
Damien Elmes
d42df6e0f1 add a temporary executemany() 2020-03-20 21:15:23 +10:00
Damien Elmes
bd7ded18c3 drop the protobuf prototype 2020-03-20 21:15:23 +10:00
Damien Elmes
38d4ea5311 use (or)json for DB bridge
Some initial testing with orjson indicates performance varies from
slightly better than pysqlite to about 2x slower depending on the type
of query.

Performance could be improved by building the Python list in rspy
instead of sending back json that needs to be decoded, but it may make
more sense to rewrite the hotspots in Rust instead. More testing is
required in any case.
2020-03-20 21:15:23 +10:00
Damien Elmes
a129b8f8cf initial work on DB handling in Rust
committing the Protobuf implementation for posterity, but will replace
it with json, as Protobuf measures about 6x slower for some workloads
like 'select * from notes'
2020-03-20 21:15:23 +10:00
Damien Elmes
1db876ba1c tweak db type hints 2020-03-20 21:15:23 +10:00
Damien Elmes
7fbc229dcd drop usage of pysqlite Cursor 2020-03-20 21:15:23 +10:00
Damien Elmes
e5a465cccb tweak layout of db methods 2020-03-20 21:15:23 +10:00
Damien Elmes
7bf27febe6 drop .cursor() 2020-03-20 21:15:23 +10:00
Damien Elmes
fb9db72dde use total_changes() sqlite func 2020-03-20 21:15:23 +10:00
Damien Elmes
45bc1cd73e drop the schema <11 upgrade code 2020-03-20 21:15:23 +10:00
Damien Elmes
fcfe1bd66c drop context manager 2020-03-20 21:15:23 +10:00
Damien Elmes
9e67ea736a drop named sql arguments 2020-03-20 21:15:23 +10:00
Damien Elmes
6d0c84a1e9 drop progress handler and timeout arg 2020-03-20 21:15:23 +10:00
Damien Elmes
45399df30d drop echo and text factory 2020-03-20 21:15:23 +10:00
Damien Elmes
923d85f66b clone db.py into dbproxy.py 2020-03-20 21:15:23 +10:00
evandrocoan
d6fecea4ff Fixed BeautifulSoup breaking string paths
https://anki.tenderapp.com/discussions/ankidesktop/39543-anki-is-replacing-the-character-by-when-i-exit-the-html-edit-mode-ctrlshiftx
2020-03-12 21:19:09 -03:00
Damien Elmes
a5021ee92e Merge pull request #501 from evandroforks/fix_beautiful_soup
Renamed BeautifulSoup import name for consistency with other usages of it
2020-03-11 15:55:15 +10:00
Damien Elmes
9a9265f113 don't error when an add-on passes None to CardStats
https://anki.tenderapp.com/discussions/beta-testing/1842-syncing-message
2020-03-11 15:18:28 +10:00
Damien Elmes
a216fbedbc Spanish is 'es' on disk 2020-03-11 14:53:19 +10:00
Damien Elmes
ea094a60da Revert "es-ES -> es"
This reverts commit 7409deae34.

This change broke Anki:

https://anki.tenderapp.com/discussions/ankidesktop/39589-lang_to_disk_lang-startup-error
2020-03-11 14:52:35 +10:00
evandrocoan
52599f364e Renamed _decode_htmlescapes s variable 2020-03-10 13:57:09 -03:00
Damien Elmes
404a8ca3ec add switch in prefs for new timezone handling code; bump sync version
AD devs: before updating the sync version to 10, please make sure
the new timezone code has been ported over. The core change to the
scheduler is in _updateCutoff():

b198ba8073/pylib/anki/schedv2.py (L1357)

with the following supporting Python functions:

b198ba8073/pylib/anki/schedv2.py (L1410)

 _timing_today() is calculated in Rust (lines up to 92, the rest are
tests):

b198ba8073/rslib/src/sched/cutoff.rs (L20)

The change went through a few iterations before stabilising, so it's
probably easier to refer to the above code than the patches that got
us to that point.
2020-03-10 17:50:18 +10:00
Damien Elmes
e512199ace add restore media action 2020-03-10 13:35:09 +10:00
Damien Elmes
cac9ccfa0d add empty trash action in aqt 2020-03-10 12:49:40 +10:00
Damien Elmes
0dc4886558 add col.weakref() and fix more reference cycles in pylib 2020-03-05 09:47:47 +10:00
Damien Elmes
0589573dfa fix retain cycle caused by col.tr
We can't use a weakref.proxy with a method, so manually proxy the
call instead.
2020-03-05 09:45:51 +10:00
Arthur Milchior
d9eb170962 hooks for limit new/rev for a single deck 2020-03-04 16:11:13 +01:00
Arthur Milchior
bf0e5f0d6e single return in sched2 _deckRevLimitSingle 2020-03-04 16:07:15 +01:00
Damien Elmes
2343ddcb02 add diffing script 2020-03-04 21:34:18 +10:00
Damien Elmes
950d39571e remove a few more common methods 2020-03-04 21:33:44 +10:00
Damien Elmes
27438d8625 use _deckLimit() in a few more places 2020-03-04 21:24:09 +10:00
Damien Elmes
db00452ded reuse _leftToday() 2020-03-04 12:26:57 +10:00
Damien Elmes
7a32a0eb6f import tidyup 2020-03-04 12:25:02 +10:00
Damien Elmes
d7c3c5d3b1 reuse _deckNewLimitSingle() 2020-03-04 12:23:56 +10:00
Damien Elmes
7bd1c59abd reuse v2's _logRev() 2020-03-04 12:23:42 +10:00
Damien Elmes
7880227b43 remove duplicate methods from sched.py 2020-03-04 12:14:26 +10:00
Damien Elmes
966cfaec84 add some type hints that were only in the v1 scheduler 2020-03-04 12:10:38 +10:00
Damien Elmes
7ab3c4ce67 make v1 scheduler inherit from v2 so we can delete duplicate code 2020-03-04 11:41:23 +10:00
Damien Elmes
28e1e01068 use weakref for backrefs so collection doesn't need to be garbage collected 2020-03-03 21:25:32 +10:00
Damien Elmes
475f8e7f04 fix backend not deallocating due to circular reference 2020-03-03 21:12:38 +10:00
Damien Elmes
e592ac06ea Merge pull request #478 from Arthur-Milchior/missing_constant
countsIdx return a queue type.
2020-03-02 15:43:31 +10:00
Alan Du
63a0b36d91 Monkeytype qt/aqt/reviewer.py 2020-03-01 10:16:08 -05:00