Commit graph

592 commits

Author SHA1 Message Date
Damien Elmes
55f4b9b7d0 favour integers, change due representation, fact&card ordering, more
- removed 'created' column from various tables. We don't care when things like
  models are created, and card creation time didn't reflect the actual time a
  card was created
- facts were previously ordered by their creation date. The code would
  manually set the creation time for subsequent facts on import by 0.0001
  seconds, and then card due times were set by adding the fact time to the
  ordinal number*0.000001. This was prone to error, and the number of zeros used
  was actually different in different parts of the code. Instead of this, we
  replace it with a 'pos' column on facts, which increments for each new fact.
- importing should add new facts with a higher pos, but concurrent updates in
  a synced deck can have multiple facts with the same pos

- due times are completely different now, and depend on the card type
- new cards have due=fact.pos or random(0, 10000)
- reviews have due set to an integer representing days since deck
  creation/download
- cards in the learn queue use an integer timestamp in seconds

- many columns like modified, lastSync, factor, interval, etc have been converted to
  integer columns. They are cheaper to store (large decks can save 10s of
  megabytes) and faster to search for.

- cards have their group assigned on fact creation. In the future we'll add a
  per-template option for a default group.

- switch to due/random order for the review queue on upgrade. Users can still
  switch to the old behaviour if they want, but many people don't care what
  it's set to, and due is considerably faster, which may result in a better
  user experience
2011-04-28 09:23:28 +09:00
Damien Elmes
11a035e2f8 change the default rev sort order to daily random; add randomize 2011-04-28 09:23:28 +09:00
Damien Elmes
7694ff81c5 replace old selective study with new lists; fix upgrade
- instead of the old 4 settings, we move to just two, as there's no point
  having separate include and exclude options for a non-overlapping set of
  cards
- revGroups and newGroups are a list of groupIds to include in the queue. If
  all groups are enabled, the UI should set it to an empty list rather than a
  list of every available group, and groupLimit() will leave off the
  constraint completely
2011-04-28 09:23:28 +09:00
Damien Elmes
4c931e0ff4 move other queue variables into qconf; discard old selective study 2011-04-28 09:23:28 +09:00
Damien Elmes
b3ee91a9d5 add index for groupId, improve startup speed
- skip updating buried cards on startup; it's expensive and we'll do that on
  deck close in the future
- add an index for groupId. Initial profiling indicates that groupId-based
  selective study is considerably faster in certain scenarios

The 50k element deck I'm testing with now opens and builds the queue in 40ms
on a cold cache, of which 34ms is the initial deck startup and 6ms the queue
build. Adding back the undo log and backups will of course increase this, but
this is a big improvement for checking due times in the deck browser.
2011-04-28 09:23:28 +09:00
Damien Elmes
bb79b0e17c add new 'groups' concept, refactor deletions
Users who want to study small subsections at one time (eg, "lesson 14") are
currently best served by creating lots of little decks. This is because:
- selective study is a bit cumbersome to switch between
- the graphs and statitics are for the entire deck
- selective study can be slow on mobile devices - when the list of cards to
  hide/show is big, or when there are many due cards, performance can suffer
- scheduling can only be configured per deck

Groups are intended to address the above problems. All cards start off in the
same group, but they can have their group changed. Unlike tags, cards can only
be a member of a single group at once time. This allows us to divide the deck
up into a non-overlapping set of cards, which will make things like showing
due counts for a single category considerably cheaper. The user interface
might want to show something like a deck browser for decks that have more than
one group, showing due counts and allowing people to study each group
individually, or to study all at once.

Instead of storing the scheduling config in the deck or the model, we move the
scheduling into a separate config table, and link that to the groups table.
That way a user can have multiple groups that all share the same scheduling
information if they want.

And deletion tracking is now in a single table.
2011-04-28 09:23:28 +09:00
Damien Elmes
abd665e48f remove queue resetting from startup; we'll do it in deck close instead 2011-04-28 09:23:28 +09:00
Damien Elmes
2613143fe9 improve dynamic indices, implement new queue 2011-04-28 09:23:28 +09:00
Damien Elmes
d34a76d5a0 move deck config into json ala models
- limits are stored separately so we can access them quickly when checking
  deck counts
- data is used to store cssCache and hexCache; these may be refactored or go
  away in the future
2011-04-28 09:23:28 +09:00
Damien Elmes
b0b4074cbd start work on learn mode, change models, more
- model config is now stored as a json-serialized dict, which allows us to
  quickly gather the info and allows for adding extra options more easily in
  the future
- denormalize modelId into the cards table, so we can get the model scheduling
  information without having to hit the facts table
- remove position - since we will handle spacing differently we don't need a
  separate variable to due to define sort order
- remove lastInterval from cards; the new cram mode and review early shouldn't
  need it
- successive->streak
- add new columns for learn mode
- move cram mode into new file; learn more and review early need more thought
- initial work on learn mode
- initial unit tests
2011-04-28 09:23:28 +09:00
Damien Elmes
4e7e8b03bc moving scheduling code into separate file, some preliminary refactoring 2011-04-28 09:23:28 +09:00
Damien Elmes
8a60ee0794 initial changes to models, deck, etc
- move most scheduling parameters from deck to models
- remove obsolete fields in deck and models
- decks->deck
- remove deck id reference in models
- move some deckVars into the deck table
- simplify deckstorage
- lock sessionhelper by default
- add models/currentModel as properties instead of ORM mappings
- remove models.tags
- remove remaining support for memory-backed databases
- use a blank string for syncName instead of null
- remove backup code; will handle in gui
- bump version to 100
- update unit tests
2011-04-28 09:23:28 +09:00
Damien Elmes
edd8f79ab9 refactor facts table
- spaceUntil->cache
- remove obsolete lastCardId
2011-04-28 09:23:28 +09:00
Damien Elmes
d9c0fba171 refactor tags
- tags.tag -> tags.name
- priority reset to 0 for now; will be used differently in the future
- cardTags.id removed; (tagId, cardId) is the primary key now
- cardTags.src -> cardTags.type
2011-04-28 09:23:28 +09:00
Damien Elmes
80153c63cb forget old gravestones on schema change 2011-04-28 09:23:28 +09:00
Damien Elmes
467eb87a48 use dueCutoff, not current time for delay calculation 2011-04-28 09:23:28 +09:00
Damien Elmes
9aa2f8dc40 refactor cards
Cards had developed quite a lot of cruft from incremental changes, and a
number of important attributes were stored in names that had no bearing to
their actual use.

Added:

- position, which new cards will be sorted on in the future
- flags, which is reserved for future use

Renamed:

- type to queue
- relativeDelay to type
- noCount to lapses

Removed:

- all new/young/matureEase counts; the information is in the revlog
- firstAnswered, lastDue, lastFactor, averageTime and totalTime for the same
  reason
- isDue, spaceUntil and combinedDue, because they are no longer used. Spaced
  cards will be implemented differently in a coming commit.
- priority
- yesCount, because it can be inferred from reps & lapses
- tags; they've been stored in facts for a long time now

Also compatibility with deck versions less than 65 has been dropped, so decks
will need to be upgraded to 1.2 before they can be upgraded by the dev code.
All shared decks are on 1.2, so this should hopefully not be a problem.
2011-04-28 09:23:27 +09:00
Damien Elmes
f828393de3 rename deck.s to a more understable deck.db; keep s for compat 2011-04-28 09:21:07 +09:00
Damien Elmes
b9cf5ad85d fix timeForNewCard(), revlog sncing, priority index del 2011-04-28 09:21:07 +09:00
Damien Elmes
b6bb03025f new history table
- rename to revlog
- change the pk to time, as we want an index on time, and the old multi-column
  index was expensive and not useful
- remove yes/no count; they can be inferred from the ease
- remove lastFactor, as it's in the previous entry
- remove delay, it can be inferred from last entry
- remove 'next' from nextInterval and nextFactor
- rename 'thinkingTime' to 'userTime'
- rename reps to rep
- migrate old data to new table, and fix some problems in the process: ease0
  -> ease1, and limit thinking time to 60 seconds as it should have been
  previously
2011-04-28 09:21:07 +09:00
Damien Elmes
855de47ffe remove the stats table
The stats table was how the early non-SQL versions of Anki kept track of
statistics, before there was a revision log. It is being removed because:

- it's not possible to show the statistics for a subset of the deck
- it can't meaningfully be copied on import/export
- it makes it harder to implement sync merging

Implications:

- graphs and deck stats roughly 1.5-3x longer than before, but we'll have the
  ability to generate stats for subsections of the deck, and it's not time
  critical code
- people who've been using anki since the very early days may notice a drop in
  statistics, as early repetitions were recorded in the stats table but the
  revlog didn't exist at that point.
- due bugs in old syncs and imports/exports, the stats and revlog may not
  match numbers exactly

To remove it, the following changes have been made:

- the graphs and deck stats now generate their data entirely from the revlog
- there are no stats to keep track of how many cards we've answered, so we
  pull that information from the revlog in reset()
- we remove _globalStats and _dailyStats from the deck
- we check if a day rollover has occurred using failedCutoff instead
- we remove the getStats() routine
- the ETA code is currently disabled
- timeboxing routines use repsToday instead of stats
- remove stats delete from export
- remove stats table and index in upgrade
- remove stats syncing and globalStats refresh pre-sync
- remove stats count check in fullSync check, which was redundant anyway
- update unit tests

Also:

- newCountToday -> newCount, to bring it in line with revCount&failedCount
  which also reflect the currently due count
- newCount -> newAvail
- timeboxing routines renamed since the old names were confusingly similar to
  refreshSession() which does something different

Todo:

- update newSeenToday & repsToday when answering a card
- reimplement eta
2011-04-28 09:21:07 +09:00
Damien Elmes
9421a037f6 remove self explanatory module docstrings; strip trailing whitespace 2011-04-28 09:21:07 +09:00
Damien Elmes
9f55c831c0 don't bother checking if temp suspended cards are modified or not 2011-04-28 09:21:07 +09:00
Damien Elmes
1a09aa9f77 remove minimum average support
Calculating the average on startup is expensive on mobile devices. It might be
nice to provide it as a deck option or per-model setting in the future so that
people can specify how hard their material is and have it treated accordingly.
2011-04-28 09:21:06 +09:00
Damien Elmes
72a1cd73a9 move upgrade code into separate file 2011-04-28 09:21:06 +09:00
Damien Elmes
4302306fe9 use a checksum for field values; fixed import->update number
Previously we had an index on the value field, which was very expensive for
long fields. Instead we use a separate column and take the first 8 characters
of the field value's md5sum, and index that. In decks with lots of text in
fields, it can cut the deck size by 30% or more, and many decks improve by
10-20%. Decks with only a few characters in fields may increase in size
slightly, but this is offset by the fact that we only generate a checksum for
fields that have uniqueness checking on.

Also, fixed import->update reporting the total # of available facts instead of
the number of facts that were imported.
2011-04-28 09:21:06 +09:00
Damien Elmes
feadce76f3 delete tombstones in integrity check as we can guarantee a full sync; optimize 2011-04-28 09:21:06 +09:00
Damien Elmes
1ddf1be747 abort the summary early if we're over the full sync threshold 2011-04-28 09:21:06 +09:00
Damien Elmes
d23a2bbe59 remove old alter table statements from long ago 2011-04-28 09:21:06 +09:00
Damien Elmes
a45dac36c4 remove some duplicate code in the upgrades 2011-04-28 09:21:06 +09:00
Damien Elmes
1a3c8c0c1e remove views and pre 0.9.9.8.6 upgrade code; upgrade test decks to 0.9.9.8.6 2011-04-28 09:21:06 +09:00
Damien Elmes
28604b9d29 remove priorities 2011-04-28 09:21:06 +09:00
Damien Elmes
73d83bc640 fixIntegrity() tweaks
- fix card ordinals too
- don't change modification time on cards, facts or models
- mark schema modified to force full sync
2011-04-28 09:21:06 +09:00
Damien Elmes
7c2b202163 timestamp schema changes 2011-04-28 09:21:06 +09:00
Damien Elmes
19a293cf74 don't return a negative delay for failed cards 2011-02-24 13:20:19 +09:00
Damien Elmes
008c5904ca when calculating delay, compare against cutoff, not current time 2011-02-20 13:45:45 +09:00
Damien Elmes
f156f81a84 don't add a mature bonus when cramming 2011-02-09 00:36:16 +09:00
Damien Elmes
8828027729 when calculating next interval ensure we don't have a negative delay 2011-02-09 00:23:45 +09:00
Damien Elmes
8a1df1728f rebuildTypes()
- ensure we're fixing relativeDelay for suspended cards
- remove priority compat code
2011-02-08 02:46:07 +09:00
Damien Elmes
ff38dad5b2 remove redundant code 2011-02-04 20:33:13 +09:00
Damien Elmes
340b5864c8 when deck is finished stop timeboxing timer 2011-02-03 00:18:42 +09:00
Damien Elmes
1464394d58 when the day rolls over, update due cutoffs too, and rebuild queue 2011-02-02 23:52:34 +09:00
Damien Elmes
e49a9bb5ac relative sibling spacing for reviews
Anki 1.0 had a similar feature but we do things a bit differently now. The
relative spacing applies only to reviews, and spaces cards according to their
interval, instead of spacing all cards the same. Any delay < 1 full day is
treated as no delay, so with the default 10% setting, reviews with an interval
< 10 days are not spaced at all. This should hopefully cut down on support
queries for people wondering why many of their cards were delayed, allows the
two settings to be documented separately, and does away with the somewhat
confusing usage of non-integer new sibling values to disable review spacing.
2011-02-02 23:47:58 +09:00
Damien Elmes
66e44f494b don't update factor in cram, learn more, etc 2011-02-02 22:12:06 +09:00
Damien Elmes
338838583e more last interval preservation into cram scheduler code 2011-02-02 22:10:44 +09:00
Damien Elmes
e0d5b9d69e never set lastSync=0 when toggling syncing
we should rely on needFullSync() to determine whether a full sync is actually
necessary.
2011-01-30 15:31:29 +09:00
Damien Elmes
d362decca2 Merge https://github.com/ymasory/libanki 2011-01-30 12:46:13 +09:00
Yuvi Masory
b0b9cd2ce3 suppress indentation 2011-01-29 22:40:29 -05:00
Damien Elmes
ab9451253c now all clients are updated, set delay1 = 0 if 600 2011-01-29 11:01:43 +09:00
Damien Elmes
523adc468e allow user to disable review spacing 2011-01-27 07:45:45 +09:00