Commit graph

205 commits

Author SHA1 Message Date
Damien Elmes
6ec898ca4b Require explicit reset for most queue-modifying functions
When you call operations like deleteCards(), suspendCards() and so on, it is
now necessary to call deck.reset() afterwards. This allows the calling code to
delay a reset if necessary. If the calling code calls a function that says the
caller must reset, the caller should be sure to call .reset() and fetch the
current card again. Failure to do the latter will result in answerCard()
attempting to remove the card from the queue, when the queue has been cleared.
2010-11-23 17:41:36 +09:00
Damien Elmes
b69fd48768 more type handling updates; don't munge counts on sync
In various parts of the code we need to get all cards of a given category
(new, failed, etc) regardless of whether they're suspended, buried, etc. So we
store the true type in the obsolete relativeDelay column and add in index for
it, because it's cheaper than putting indices on reps & successive.
2010-11-13 18:39:24 +09:00
Damien Elmes
6ed0bc91bb update sync url 2010-11-08 09:22:36 +09:00
Damien Elmes
e0d46f0f12 be resilient if spaceUntil sent wrong 2010-11-06 07:50:05 +09:00
Damien Elmes
46790f2e92 remove (incorrect) code in sync, is covered on deck load anyway 2010-11-02 22:34:10 +09:00
Damien Elmes
2c5ac66083 type/priority changes, cram/rev early refactor, more
* Adjust type to remove cards from the queues, so we don't have to rebuild
  priorities to restore them:

Type -= 3 when suspending
Type += 3 when burying
Type += 6 when cramming / reviewing early

We still need to adjust priorities for backwards compatibility, but this can
be removed in the future.

* Factor out scheduler-specific code in answerCard(), so the different
  schedulers are now fully modular

* Differentiate between a card's current queue and its type

* Make sure dueCutoff cuts off at the chosen offset instead of midnight
2010-11-02 01:59:20 +09:00
Damien Elmes
ad743d850d start work on scheduling refactor
Previously we used getCard() to fetch a card at the time. This required a
number of indices to perform efficiently, and the indices were expensive in
terms of disk space and time required to keep them up to date. Instead we now
gather a bunch of cards at once.

- Drop checkDue()/isDue so writes are not necessary to the DB when checking
for due cards
- Due counts checked on deck load, and only updated once a day or at the end
of a session. This prevents cards from expiring during reviews, leading to
confusing undo behaviour and due counts that go up instead of down as you
review. The default will be to only expire cards once a day, which represents
a change from the way things were done previously.
- Set deck var defaults on deck load/create instead of upgrade, which should
fix upgrade issues
- The scheduling code can now have bits and pieces switched out, which should
make review early / cram etc easier to integrate
- Cards with priority <= 0 now have their type incremented by three, so we can
get access to schedulable cards with a single column.
- rebuildQueue() -> reset()
- refresh() -> refreshSession()
- Views and many of the indices on the cards table are now obsolete and will
  be removed in the future. I won't remove them straight away, so as to not
  break backward compatibility.
- Use bigger intervals between successive card templates, as the previous
intervals were too small to represent in doubles in some circumstances

Still to do:

- review early
- learn more
- failing mature cards where delay1 > delay0
2010-10-18 14:35:11 +09:00
Damien Elmes
8df9111b50 only copy used media on import/export 2010-10-16 10:29:39 +09:00
Damien Elmes
e010ef8062 add clock skew compensation again
this has the negative effect of causing multiple full syncs if syncing
multiple times within a 5 minute period of the previous full sync, but it
makes it much less likely that people's due counts will fall out of sync
2010-10-02 14:47:33 +09:00
Damien Elmes
99ba3f09c8 catch missing facts at end of sync 2010-09-12 12:21:39 +09:00
Damien Elmes
5e7c62bca5 don't compensate for clock skew 2010-07-30 18:15:24 +09:00
Damien Elmes
e956aa9afb remove obsolete function 2010-07-27 22:54:51 +09:00
Damien Elmes
d3fb189a72 improved lastSync/modified handling
- never bump deck mod while syncing
- set lastSync to current time, not deck modified time
- don't update lastSync until the final part of the sync
- lower clock skew allowance to ~5 minutes
- bump full sync threshold to 1000 modified items
2010-07-27 22:46:04 +09:00
Damien Elmes
55194f8aa7 ensure cardmodel/fieldmodels work when given a string too 2010-07-26 17:15:05 +09:00
Damien Elmes
61a7d6d79e make sure we match a given model even when given a string 2010-07-24 14:28:24 +09:00
Damien Elmes
6852b0acda bump mod time on full sync to server, ensure lastSync matches 2010-07-21 18:37:05 +09:00
Damien Elmes
f03000d27b remove string exceptions for python2.6 2010-06-10 13:24:46 +09:00
Damien Elmes
5616e679f5 cache the css as a deck var, don't accidentally send it in sync 2010-05-10 21:32:36 +09:00
Damien Elmes
fd1953bfb5 convert to a list, not tuples, so we can modify on the fly 2010-05-07 16:05:35 +09:00
Damien Elmes
c8d9bac5df clarify one way sync error 2010-03-05 09:27:11 +09:00
Damien Elmes
7c8e612704 use a constant for chunk size 2010-02-18 17:36:54 +09:00
Damien Elmes
33ec7ce133 clarify comment 2009-12-02 03:38:46 +09:00
Damien Elmes
093395b9e0 Revert "add 30 second timeout to all sync ops"
This reverts commit cbc23e5231.
2009-11-24 23:35:34 +09:00
Damien Elmes
cbc23e5231 add 30 second timeout to all sync ops 2009-10-04 19:53:12 +09:00
Damien Elmes
164b0583c3 unlink tmp file after full up 2009-10-04 19:33:18 +09:00
Damien Elmes
75f56d13e2 decrease chunk size to 32k due to crappy win32 network cards 2009-09-26 05:51:22 +09:00
Damien Elmes
27732e3553 catch large # of reviews in full sync, reduce limit to 500 2009-06-25 05:47:14 +09:00
Damien Elmes
6b7c0d7997 fix missing media problem, fix json decode float 2009-06-21 04:36:36 +09:00
Damien Elmes
1f0a8edfa4 strip out mediaSupported 2009-06-20 01:32:20 +09:00
Damien Elmes
3d81181323 bulk media support -> local media copy, always send media table 2009-06-19 11:50:31 +09:00
Damien Elmes
f96a7a7c5b Reverting "suspend/unsuspend noweb on full sync"; obsolete 2009-06-19 10:10:37 +09:00
Damien Elmes
093fb4695b suspend/unsuspend noweb on full sync 2009-06-18 04:04:50 +09:00
Damien Elmes
03369658ee remove sleep debugging 2009-06-16 04:01:13 +09:00
Damien Elmes
717044dcad add progress handler back to full sync upload 2009-06-16 03:59:54 +09:00
Damien Elmes
5b8832402a fix close post sync 2009-06-16 00:02:26 +09:00
Damien Elmes
3b99232f7a switch to urllib2 to pick up proxy, monkey-patch httplib to incrementally send 2009-06-15 23:01:43 +09:00
Damien Elmes
efb71c754c bump protocol version 2009-06-13 01:14:54 +09:00
Damien Elmes
28f6df93cb assert response ok 2009-06-10 22:33:20 +09:00
Damien Elmes
fe6fb005b6 do partial tag update on sync 2009-06-10 20:58:54 +09:00
Damien Elmes
d1c73cb002 don't use full sync in local sync 2009-06-06 01:11:14 +09:00
Damien Elmes
f5facee398 make sure to close temp file fds, add full sync to sync() 2009-06-05 15:16:11 +09:00
Damien Elmes
4b883e2c16 don't clobber original deck if failure in sync 2009-06-02 15:41:30 +09:00
Damien Elmes
d35ef18889 make sure to set host header 2009-06-02 04:16:49 +09:00
Damien Elmes
a1166215fd implement full sync downloading 2009-06-02 03:19:16 +09:00
Damien Elmes
8a19bd4c57 implement full sync uploading 2009-05-31 01:23:31 +09:00
Damien Elmes
df0e4d2446 ensure tags are synced properly in one way sync 2009-05-21 02:11:33 +09:00
Damien Elmes
1e275db81d add stats sync direction to make it clearer 2009-05-13 15:41:31 +09:00
Damien Elmes
4a59e9d5ae patch to fix sync translation from piotr 2009-04-30 05:21:52 +09:00
Damien Elmes
19584bd642 don't dirty cards on sync 2009-04-22 21:57:25 +09:00
Damien Elmes
d4235aaa34 parse lastSync as a float to fix problem with latest simplejson 2009-04-11 01:05:35 +09:00
Damien Elmes
ba716e2066 conditionally apply meta 2009-04-07 12:22:35 +09:00
Damien Elmes
c7f9cec657 add deck vars 2009-04-07 11:55:08 +09:00
Damien Elmes
aed9fb1c61 update tag priorities when deck is bundled 2009-04-06 23:53:04 +09:00
Damien Elmes
64275642ba pass unicode to simplejson.loads() 2009-03-15 06:39:08 +09:00
Damien Elmes
b527d31499 fix the review history growing bug properly 2009-03-12 17:21:11 +09:00
Damien Elmes
0b1a135176 update card tags after sync, new priority handling 2009-02-20 00:12:19 +09:00
Damien Elmes
77a6488f6d when importing, tag cards as new, add unit test 2009-02-14 03:03:42 +09:00
Damien Elmes
8c9803e638 dynamic index generation, sort new in rev order 2009-02-06 01:28:21 +09:00
Damien Elmes
d0fa667717 don't report deletions when renamed, assert checksum on client 2009-02-04 22:33:49 +09:00
Damien Elmes
89a31fdc9a don't checksum media locally 2009-02-04 22:24:54 +09:00
Damien Elmes
b1835ff71b no need to replace into, since we delete fields anyway 2009-02-04 18:00:00 +09:00
Damien Elmes
ded420dd9e fix allow empty answer problem in sync 2009-01-21 16:20:42 +09:00
Samson Melamed
314f6c9b1f fixes media sync progress bar not reaching 100% 2009-01-10 00:00:48 -05:00
Damien Elmes
2b30578615 make sure to commit lastSync on summary, don't force table size 2009-01-07 10:56:32 +09:00
Damien Elmes
a0a6df0f8e fix problems with lastsync 2008-12-23 15:41:22 +09:00
Damien Elmes
8a47538075 use lastsync not deck.lastsync 2008-12-20 18:30:02 +09:00
Damien Elmes
d027892c5c always downcase media extensions, fix path on win32 2008-12-13 13:40:14 +09:00
Damien Elmes
a0adccc117 replace facts, don't ignore them 2008-11-29 00:13:59 +09:00
Damien Elmes
8af4c1200f don't fail silently 2008-11-21 13:36:19 +09:00
Damien Elmes
9c8af9d64f work around a sync bug 2008-11-21 13:16:48 +09:00
Damien Elmes
26ad7e8149 rebuild due counts after sync 2008-11-16 04:20:14 +09:00
Damien Elmes
9775213845 protocol 4 sync 2008-11-15 00:41:24 +09:00
Damien Elmes
7c630b9805 change 60 to 30 2008-11-14 14:06:21 +09:00
Damien Elmes
d747745f13 increase sync timeout to 60 seconds 2008-11-14 14:06:00 +09:00
Damien Elmes
cdd2be3548 fix unit test, badstatusline error 2008-11-14 14:03:47 +09:00
Damien Elmes
07956d9e24 new bulk card handling, fix count bugs, next int generation 2008-11-13 03:19:19 +09:00
Damien Elmes
e9dc034b9a add refs to relativeDelay again 2008-11-08 20:05:39 +09:00
Damien Elmes
014896478f Merge branch 'master' into htmlcache
Conflicts:

	anki/deck.py
2008-11-08 17:26:45 +09:00
Damien Elmes
4558a36d3a obsolote relativeDelay in favour of interval desc, should fix ubuntu too 2008-11-08 16:30:41 +09:00
Damien Elmes
b2d0e5d3df wip 2008-11-07 18:44:49 +09:00
Damien Elmes
83bc433e19 media syncing fix 2008-11-06 22:35:50 +09:00
Damien Elmes
4ecf764046 reenable history syncing 2008-10-19 20:25:03 +09:00
Damien Elmes
ef3e1c3da4 properly send protocol version 2008-10-19 20:22:20 +09:00
Damien Elmes
5a21a79eb8 disable applying history too, until people upgrade 2008-10-19 18:56:11 +09:00
Damien Elmes
c130dac060 temporarily disable history, add canonifyTags 2008-10-19 18:46:05 +09:00
Damien Elmes
bb2c38e723 reimplement history sync in raw sql 2008-10-19 03:03:04 +09:00
Damien Elmes
c0e5bed6a6 sync sources, support media syncing in import/export again 2008-10-18 20:20:43 +09:00
Damien Elmes
2afa59b24a remove sync limit, improve bulk media 2008-10-18 19:10:29 +09:00
Damien Elmes
06d1f713b5 fix a big sync bug 2008-10-16 11:08:09 +09:00
Damien Elmes
8f78965a2d bulk media uploader/downloader 2008-10-16 03:05:42 +09:00
Damien Elmes
6a98c1bc64 mark objects undeleted when adding 2008-10-16 00:31:45 +09:00
Damien Elmes
5053f07077 fix noweb update 2008-10-15 13:39:56 +09:00
Damien Elmes
b0ad2be961 use unicode tags, don't go under 0 in sync timestamp 2008-10-12 04:46:14 +09:00
Damien Elmes
838ed803f7 prevent merging/deletion of public models, add source id 2008-10-12 02:59:31 +09:00
Damien Elmes
e25feed0af support 4am rollover 2008-10-12 04:02:33 +09:00
Damien Elmes
23379cd600 get rid of 'deck is empty message' 2008-10-12 00:19:58 +09:00
Damien Elmes
0d87b6f32d set timeout to 10 seconds on sync 2008-10-11 18:19:18 +09:00
Damien Elmes
a0f54015b3 change sync url 2008-10-09 17:26:49 +09:00
Damien Elmes
e69522f120 ensure order of received cards 2008-10-06 18:41:50 +09:00
Damien Elmes
ef9f6bf051 bump mod-time post sync, support public deck name 2008-10-05 12:03:21 +09:00
Damien Elmes
fd212883b6 remove superfluous error checks, use simplejson to write sources 2008-10-04 15:18:18 +09:00
Damien Elmes
472eb4581a public decks wip 2008-10-04 14:48:23 +09:00
Damien Elmes
1561655461 start of one way syncing 2008-10-02 17:57:44 +09:00
Damien Elmes
85c72a9ddb forget deletions in integrity check 2008-10-01 03:16:52 +09:00
Damien Elmes
5da3a0f5d3 initial commit from hg 2008-09-27 23:50:03 +09:00