Commit Graph

353 Commits

Author SHA1 Message Date
Damien Elmes
f52e775354 NoteTypeID 2020-03-26 15:00:24 +10:00
Damien Elmes
4ec30e412a newtype NoteID 2020-03-26 14:42:43 +10:00
Damien Elmes
5eed3d7f71 use a macro for newtype defs 2020-03-26 13:50:20 +10:00
Damien Elmes
39f916a23e usn newtype 2020-03-26 13:06:02 +10:00
Damien Elmes
eb89a2db3f use newtypes for distinguishing between second and millisecond stamps 2020-03-26 12:59:51 +10:00
Damien Elmes
289bdde20c handle fields with embedded nuls 2020-03-24 14:53:33 +10:00
Damien Elmes
11a4d582b4 convert asc to desc instead of appending desc to the end of the order
as the latter doesn't work when sorting on more than one column

https://anki.tenderapp.com/discussions/beta-testing/1868-anki-2124-beta#comment_48174812
2020-03-23 19:53:57 +10:00
Damien Elmes
14a970e923 rename long filenames in fields if files renamed in a previous sync 2020-03-23 18:38:45 +10:00
Damien Elmes
4e2e0d1b84 fix setting of wal 2020-03-23 13:52:57 +10:00
Damien Elmes
430f1ad616 handle trailing whitespace inside group 2020-03-22 18:52:44 +10:00
Damien Elmes
25ff4642ec accept now_mins_west for v2 legacy timing as well 2020-03-22 17:33:14 +10:00
Damien Elmes
69d8cdd9ed use backend for v1 and v2 cutoff calculations
this should also fix the CI failures, which were happening because
the datetime module wasn't matching the shifted time.time()
2020-03-22 14:28:26 +10:00
Damien Elmes
47fcdd0723 possible fix for CI failure 2020-03-22 13:17:00 +10:00
Damien Elmes
f28e57a367 add enum for controlling sort order
eg col.find_cards("", order=BuiltinSortKind.CARD_DUE)
2020-03-22 12:59:24 +10:00
Damien Elmes
199713a39a handle collections with sortBackwards set to 0 instead of a bool 2020-03-22 10:26:09 +10:00
Damien Elmes
cc44523449 remove debugging line 2020-03-21 18:29:04 +10:00
Damien Elmes
9696e959be increase the rated search cap to 365, and allow searches for ease 0
An add-on appears to use ease 0 when rescheduling cards, and it may
make sense for Anki to do the same in the future as well.
2020-03-21 16:05:17 +10:00
Damien Elmes
51a379de23 add search that ignores combining chars
On a test of a ~40k card collection, the 'ignore accents' add-on
takes about 1150ms, and this code takes about 70ms.
2020-03-21 15:15:59 +10:00
Damien Elmes
f0ed34d79b support regexp search in single field 2020-03-21 13:06:46 +10:00
Damien Elmes
97577dbc16 support wildcard in field*:val search 2020-03-21 12:45:25 +10:00
Damien Elmes
08e64d246d don't require wildcard for unicode case folding in search 2020-03-21 12:44:56 +10:00
Damien Elmes
4ff17d31b3 add unicase collation
sqlite's like is hard-coded to use ASCII comparisons, so we can't
take advantage of this yet
2020-03-21 12:40:20 +10:00
Damien Elmes
d1ebdbdcce support regex searches 2020-03-21 12:00:48 +10:00
Damien Elmes
2dc1b5c982 add regexp() to sqlite 2020-03-21 10:23:11 +10:00
Damien Elmes
2aab44d9ce support deck:"foo bar" style searches 2020-03-21 09:34:24 +10:00
Damien Elmes
a5787781d7 add note searching 2020-03-21 09:00:05 +10:00
Damien Elmes
aee64016ac fix formatting and unit test 2020-03-21 08:17:24 +10:00
Damien Elmes
3a4146560c handle escaped tag searches and tag:* special case 2020-03-21 08:09:28 +10:00
Damien Elmes
ad09c89c3c check for child decks case-insensitively 2020-03-21 07:57:07 +10:00
Damien Elmes
c3314d3689 don't crash when card:0 passed in 2020-03-21 07:56:55 +10:00
Damien Elmes
124357bd82 handle * in single-field search 2020-03-21 07:56:32 +10:00
Damien Elmes
949252d438 fix ease search 2020-03-21 07:56:09 +10:00
Damien Elmes
5debd3e0f8 add the ability to provide a custom sort order; use backend for find 2020-03-21 07:55:21 +10:00
Damien Elmes
09a76967e7 support sorting on tags
I don't personally understand it, but some users seem to want it.
2020-03-20 21:15:23 +10:00
Damien Elmes
00d0447ecb support sorting on note type, card template and decks 2020-03-20 21:15:23 +10:00
Damien Elmes
2c362d6991 search order 2020-03-20 21:15:23 +10:00
Damien Elmes
d94effcdc7 fix is:new/is:review 2020-03-20 21:15:23 +10:00
Damien Elmes
79697746a4 added needs to use milliseconds 2020-03-20 21:15:23 +10:00
Damien Elmes
c90670ec3a tolerate some string IDs 2020-03-20 21:15:23 +10:00
Damien Elmes
224bad2566 handle empty searches and leading/trailing whitespace 2020-03-20 21:15:23 +10:00
Damien Elmes
67cb27bada add remaining tests and fix some clippy lints 2020-03-20 21:15:23 +10:00
Damien Elmes
8c158a3897 fix rated and state searches 2020-03-20 21:15:23 +10:00
Damien Elmes
37ad664afc fix tags, more tests 2020-03-20 21:15:23 +10:00
Damien Elmes
fa654a0e22 fix cards 2020-03-20 21:15:23 +10:00
Damien Elmes
425a9d04ca fix decks 2020-03-20 21:15:23 +10:00
Damien Elmes
2693e142aa fix added 2020-03-20 21:15:23 +10:00
Damien Elmes
5df04b161c fix qualified search 2020-03-20 21:15:23 +10:00
Damien Elmes
c723adea17 fix escape handling, and handle sql wildcards 2020-03-20 21:15:23 +10:00
Damien Elmes
b70668d31c avoid extra sql binding in unqualified search 2020-03-20 21:15:23 +10:00
Damien Elmes
1f9e8e388a start on search tests 2020-03-20 21:15:23 +10:00
Damien Elmes
bca5f2ddff prototype of integration
no ordering yet, and no tests
2020-03-20 21:15:23 +10:00
Damien Elmes
9752de5aaa finish the remaining searches
Searches that require multiple deck or note type lookups won't perform
very well at the moment - it either needs caching or to be split up
at the DB level.

Nothing tested yet.
2020-03-20 21:15:23 +10:00
Damien Elmes
85af35509d ctx->req 2020-03-20 21:15:23 +10:00
Damien Elmes
dc12c23ce9 add timing to search 2020-03-20 21:15:23 +10:00
Damien Elmes
2beccd377b add v1 and v2 legacy timing code 2020-03-20 21:15:23 +10:00
Damien Elmes
9f3cc0982d deck searching
A bit more complicated than it needs to be, as we don't have the
full deck manager infrastructure yet.
2020-03-20 21:15:23 +10:00
Damien Elmes
f559ae3ef8 address some clippy lints 2020-03-20 21:15:23 +10:00
Damien Elmes
cc54e92756 move html stripping out of field_checksum into caller 2020-03-20 21:15:23 +10:00
Damien Elmes
7eab504126 add field_at_index() sql func 2020-03-20 21:15:23 +10:00
Damien Elmes
cffa52ff82 more searching work 2020-03-20 21:15:23 +10:00
Damien Elmes
761d1d1812 add card queue/type enums 2020-03-20 21:15:23 +10:00
Damien Elmes
91d7b02325 separate out template ordinal and name search 2020-03-20 21:15:23 +10:00
Damien Elmes
dcb2b46d1b use .eq_ignore_ascii_case() to avoid allocating 2020-03-20 21:15:23 +10:00
Damien Elmes
68657c7166 field_checksum needs to strip HTML 2020-03-20 21:15:23 +10:00
Damien Elmes
4f93ae4b6d start of searching sql 2020-03-20 21:15:23 +10:00
Damien Elmes
00300bb24d ensure rated ease in range 2020-03-20 21:15:23 +10:00
Damien Elmes
e790367b1e ensure id list not empty 2020-03-20 21:15:23 +10:00
Damien Elmes
08d205d377 decode search terms in parser 2020-03-20 21:15:23 +10:00
Damien Elmes
289318d92c split up searches with a qualifier 2020-03-20 21:15:23 +10:00
Damien Elmes
f623f19b3d basic search parsing 2020-03-20 21:15:23 +10:00
Damien Elmes
72bcef917e release mutex before beginning media sync
And check media sync is not running on close
2020-03-20 21:15:23 +10:00
Damien Elmes
5f19048c93 fix media sync being logged to console 2020-03-20 21:15:23 +10:00
Damien Elmes
ba17567617 drop the separate i18n backend 2020-03-20 21:15:23 +10:00
Damien Elmes
874bc085fe support opening and closing the DB while keeping backend alive
This is safer than just dropping the backend, as .close() will
block if something else is holding the mutex. Also means we can
drop the extra I18nBackend code.

Media syncing still needs fixing.
2020-03-20 21:15:23 +10:00
Damien Elmes
94e4c40ebf move media folder/db paths into collection
this breaks background media syncing for now
2020-03-20 21:15:23 +10:00
Damien Elmes
649b40371b drop unused col_path 2020-03-20 21:15:23 +10:00
Damien Elmes
1322d8c617 make the collection optional 2020-03-20 21:15:23 +10:00
Damien Elmes
db1508e27c support first_row_only 2020-03-20 21:15:23 +10:00
Damien Elmes
e14c5e4745 proper implementation of executemany(); drop executescript() 2020-03-20 21:15:23 +10:00
Damien Elmes
14546c8a8b wrap the collection in a mutex so DB access is thread safe 2020-03-20 21:15:23 +10:00
Damien Elmes
47c142a74c move note code into notes.rs, add ability to rollback when unchanged 2020-03-20 21:15:23 +10:00
Damien Elmes
ae06b9e446 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
2cd7885ec0 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
b51e575a9d drop the protobuf prototype 2020-03-20 21:15:23 +10:00
Damien Elmes
b876d97770 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
04ca8ec038 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
e3a57a4193 fix clippy lint on other platforms 2020-03-19 10:58:52 +10:00
Damien Elmes
617b18ff49 correctly handle NFD content in media DB from older Anki versions 2020-03-19 10:20:42 +10:00
Damien Elmes
5e676db4a0 fix fallback preferences being used instead of English
Check needs to be done regardless of if we found a regional variant
or not.
2020-03-12 18:02:15 +10:00
Damien Elmes
9736e4a970 ignore remote file links in media check 2020-03-10 13:46:52 +10:00
Damien Elmes
0f4c3ab611 add restore media action 2020-03-10 13:35:09 +10:00
Damien Elmes
6ad2a1f9a3 add empty trash action in aqt 2020-03-10 12:49:40 +10:00
Damien Elmes
255d6f8af7 don't clean up the trash folder automatically
The media check now reports if any files are in the trash folder,
and a method has been exposed to clear the trash.
2020-03-10 12:02:38 +10:00
Damien Elmes
67d6b4f713 add basic log rotation 2020-03-10 10:33:14 +10:00
Damien Elmes
6e30572e6d log sync errors 2020-03-10 09:43:48 +10:00
Damien Elmes
b4af0ca825 tweak logging 2020-03-10 09:30:05 +10:00
Damien Elmes
18cd841246 don't try to read file data when file marked as a deletion
If the user hadn't used the media check to clean up files with
invalid names on disk,  the long filename would break the 'automatically
rename long filenames when syncing' functionality, causing the original
long filename to be uploaded to AnkiWeb as an addition instead of
a deletion
2020-03-10 09:29:36 +10:00
Damien Elmes
2f20be7a5a fix incorrect mark_collection_modified()
- usn shouldn't be changed
- mtime is in milliseconds
2020-03-05 14:55:03 +10:00
Damien Elmes
ba4fe71eba make logging explicit, and support logging to a file 2020-02-29 20:44:01 +10:00
Damien Elmes
3a1fc74ec3 remove some unused imports 2020-02-29 15:21:11 +10:00
Damien Elmes
801c5fcc40 don't require a media scan after media deleted inside Anki 2020-02-29 14:45:16 +10:00
Damien Elmes
4781ed4d70 fix display of years 2020-02-28 17:14:35 +10:00
Damien Elmes
b4c3bf99ab extra newline in network details 2020-02-27 11:22:48 +10:00
Damien Elmes
67942b54f5 use debug description for untranslated errors; fix template error 2020-02-27 11:07:18 +10:00
Damien Elmes
b610ff781f info is superfluous 2020-02-27 10:53:49 +10:00
Damien Elmes
644670d0d6 return a localized error for all error kinds
some errors are not yet localized, but now the Python code
doesn't need to think about which property to use
2020-02-27 10:46:24 +10:00
Damien Elmes
fbbbbd6a7d tweak rounding
- avoid rounding minutes
- round the seconds taken in the card info screen
- provide different precise and imprecise modes, since we need
to display seconds to multiple decimals in some areas
2020-02-25 17:29:06 +10:00
Damien Elmes
b1a192b384 cap answer buttons to 1 decimal place
we can switch to NUMBER() instead in the future, but will need
to update all the translations at the same time
2020-02-25 13:24:29 +10:00
Damien Elmes
c58b4158a7 use Fluent's number formatting; don't show trailing zeros
We can add NUMBER() in the future for more control, but this will
do for the time being.
2020-02-25 13:22:41 +10:00
Damien Elmes
9f7c3a2fcf expand clozes before rendering LaTeX
https://anki.tenderapp.com/discussions/ankidesktop/39071-latex-media-windows-version-2121-683b7983-fail-rendering-latex
2020-02-24 18:34:08 +10:00
Damien Elmes
0e931808c9 translations no longer require an open collection 2020-02-23 14:57:02 +10:00
Damien Elmes
4430c67069 rework Fluent handling
- all .ftl files for a language are concatenated into a single file
at build time
- all languages are included in the binary
- external ftl files placed in the ftl folder can override the
built-in definitions
- constants are automatically generated for each string key
- dropped the separate StringsGroup enum
2020-02-23 13:22:50 +10:00
Damien Elmes
05d7852910 fix message references 2020-02-22 21:48:14 +10:00
Damien Elmes
ecc0298f65 add file prefix to fluent keys so we can merge the files at build 2020-02-22 20:26:15 +10:00
Damien Elmes
f8c4fb5e29 make sure English takes priority if it's listed first 2020-02-21 22:01:35 +10:00
Damien Elmes
6fd3d1e8b4 add deck config category 2020-02-21 20:53:20 +10:00
Damien Elmes
f4b9aff58a reviews 2020-02-21 20:36:22 +10:00
Damien Elmes
9744736273 fix comment 2020-02-21 20:10:58 +10:00
Damien Elmes
972aee5f7a add next learning due time + remaining count to congrats screen
https://anki.tenderapp.com/discussions/ankidesktop/38000-v2-scheduler-learning-cards
2020-02-21 19:54:50 +10:00
Damien Elmes
49fe080636 add studied_today(), move to statistics.ftl 2020-02-21 18:01:15 +10:00
Damien Elmes
0fbe59cd57 add average-answer-time to Fluent
drop the 0.1 special case; we're using two decimals now
2020-02-21 17:42:55 +10:00
Damien Elmes
71e7568904 remove unused import 2020-02-21 15:29:38 +10:00
Damien Elmes
d69a98a0d4 add 'studied-today' to Fluent
The string has been constructed in parts so the old translations
could be preserved
2020-02-21 15:29:38 +10:00
Damien Elmes
2fc15d0d3a add non-abbreviated timespan translation; update existing short=True calls
- drop the '5m3s' special casing done in the card stats screen, and
just use decimals
- change alignment of the review log so that the non-abbreviated
spans are easier to read
2020-02-21 15:29:38 +10:00
Damien Elmes
99c07cfdcb move answer_button_time to the backend, split sched into separate module 2020-02-21 15:29:38 +10:00
Damien Elmes
232a8625bf move answer button labels into fluent 2020-02-21 15:29:38 +10:00
Damien Elmes
370bb38b8b update to latest fluent-rs and add basic locale-aware decimals
- git version pinned at the moment until the concurrency fix
lands in 0.10.2
- currently float values are hard-coded at 2 decimal places;
we should switch to using NUMBER() in the future
2020-02-21 15:29:38 +10:00
Damien Elmes
e0951e4cfe add 'new #' prefix to new cards in the due column 2020-02-18 11:16:15 +10:00
Damien Elmes
44053f0715 fix deletion notices being sent unnecessarily 2020-02-17 17:21:58 +10:00
Damien Elmes
1524e7dcac split "Due" into three different contexts for translators 2020-02-17 14:41:01 +10:00
Damien Elmes
771452c227 media check required message is no longer required 2020-02-17 13:51:33 +10:00
Damien Elmes
cb9ebf748c match older string 2020-02-17 13:41:02 +10:00
Damien Elmes
63f08535e9 add some more comments 2020-02-17 11:43:18 +10:00
Damien Elmes
d612aa0945 localize some error messages 2020-02-17 11:38:22 +10:00
Damien Elmes
67a741958c use new i18n infrastructure for more media check / media sync strings 2020-02-17 10:18:20 +10:00
Damien Elmes
0217cff099 add some comments to card-template-rendering.ftl 2020-02-17 09:06:54 +10:00
Damien Elmes
c395003def expose translations to Python 2020-02-17 08:40:17 +10:00
Damien Elmes
4fe47b7be4 cache i18n categories 2020-02-17 08:40:17 +10:00
Damien Elmes
9247e5de7d don't hard-code available ftl languages
Instead of trying to define which languages we support, just check
if an appropriate folder is available on disk. This allows users
to drop their own translations into the locale folder and have things
just work.
2020-02-17 08:40:17 +10:00
Damien Elmes
8cd76bee92 wrap i18n struct in a shared mutex so we can start caching 2020-02-17 08:40:17 +10:00
Damien Elmes
f6a881f950 pass progress back as translated string(s) 2020-02-17 08:40:17 +10:00
Damien Elmes
d1e587fca9 add ftl to the build process, and a sync-git script
also
- ensure po files are checked when updated
- add start of sync.ftl
2020-02-17 08:40:17 +10:00
Damien Elmes
cc99f221be expose StringsGroup enum in protobuf 2020-02-17 08:40:17 +10:00
Damien Elmes
319390f0c6 more frequent progress updates 2020-02-17 08:40:17 +10:00
Damien Elmes
b8e516b47c rename card-templates.ftl 2020-02-17 08:40:17 +10:00
Damien Elmes
0cc1938657 move empty card check into template code 2020-02-17 08:40:17 +10:00
Damien Elmes
33367c8edf make template errors translatable 2020-02-17 08:40:17 +10:00
Damien Elmes
5c8e3df612 include report in MediaCheckOutput 2020-02-17 08:40:17 +10:00
Damien Elmes
dc9362d4ed add i18n support to Rust code using Fluent 2020-02-17 08:40:17 +10:00
Damien Elmes
ee27711b65 remove redundant test_ prefix 2020-02-17 08:40:17 +10:00