Commit graph

114 commits

Author SHA1 Message Date
Damien Elmes
9705dbdcfe small tweaks 2011-04-28 09:24:01 +09:00
Damien Elmes
fba161d0b1 tablify info 2011-04-28 09:24:01 +09:00
Damien Elmes
5dc418060e fix forecost avg calculation 2011-04-28 09:24:00 +09:00
Damien Elmes
02b1494a10 improve review time data; make sure graph bounds include end points 2011-04-28 09:24:00 +09:00
Damien Elmes
4c8eec5659 duplicate imports 2011-04-28 09:24:00 +09:00
Damien Elmes
84d2f32685 move graph code into stats.py; remove old deck stats 2011-04-28 09:24:00 +09:00
Damien Elmes
cf43d23edd fix factor 2011-04-28 09:23:57 +09:00
Damien Elmes
6b736f9f54 change deck stats layout 2011-04-28 09:23:57 +09:00
Damien Elmes
942bf43b52 fix stats
they're running now, but need to be sanity checked to make sure they're doing the right thing
2011-04-28 09:23:57 +09:00
Damien Elmes
9e46db5b3e update finished msg 2011-04-28 09:23:56 +09:00
Damien Elmes
908dccc2c0 implement new review code, add unit tests
Instead of the old approach to sibling spacing, we instead try to pick a due
date that doesn't have any siblings.
2011-04-28 09:23:56 +09:00
Damien Elmes
2f27133705 drop sqlalchemy; massive refactor
SQLAlchemy is a great tool, but it wasn't a great fit for Anki:
- We often had to drop down to raw SQL for performance reasons.
- The DB cursors and results were wrapped, which incurred a
  sizable performance hit due to introspection. Operations like fetching 50k
  records from a hot cache were taking more than twice as long to complete.
- We take advantage of sqlite-specific features, so SQL language abstraction
  is useless to us.
- The anki schema is quite small, so manually saving and loading objects is
  not a big burden.

In the process of porting to DBAPI, I've refactored the database schema:
- App configuration data that we don't need in joins or bulk updates has been
  moved into JSON objects. This simplifies serializing, and means we won't
  need DB schema changes to store extra options in the future. This change
  obsoletes the deckVars table.
- Renamed tables:
-- fieldModels -> fields
-- cardModels -> templates
-- fields -> fdata
- a number of attribute names have been shortened

Classes like Card, Fact & Model remain. They maintain a reference to the deck.
To write their state to the DB, call .flush().

Objects no longer have their modification time manually updated. Instead, the
modification time is updated when they are flushed. This also applies to the
deck.

Decks will now save on close, because various operations that were done at
deck load will be moved into deck close instead. Operations like undoing
buried card are cheap on a hot cache, but expensive on startup.
Programmatically you can call .close(save=False) to avoid a save and a
modification bump. This will be useful for generating due counts.

Because of the new saving behaviour, the save and save as options will be
removed from the GUI in the future.

The q/a cache and field cache generating has been centralized. Facts will
automatically rebuild the cache on flush; models can do so with
model.updateCache().

Media handling has also been reworked. It has moved into a MediaRegistry
object, which the deck holds. Refcounting has been dropped - it meant we had
to compare old and new value every time facts or models were changed, and
existed for the sole purpose of not showing errors on a missing media
download. Instead we just media.registerText(q+a) when it's updated. The
download function will be expanded to ask the user if they want to continue
after a certain number of files have failed to download, which should be an
adequate alternative. And we now add the file into the media DB when it's
copied to th emedia directory, not when the card is commited. This fixes
duplicates a user would get if they added the same media to a card twice
without adding the card.

The old DeckStorage object had its upgrade code split in a previous commit;
the opening and upgrading code has been merged back together, and put in a
separate storage.py file. The correct way to open a deck now is import anki; d
= anki.Deck(path).

deck.getCard() -> deck.sched.getCard()
same with answerCard
deck.getCard(id) returns a Card object now.

And the DB wrapper has had a few changes:
- sql statements are a more standard DBAPI:
 - statement() -> execute()
 - statements() -> executemany()
- called like execute(sql, 1, 2, 3) or execute(sql, a=1, b=2, c=3)
- column0 -> list
2011-04-28 09:23:53 +09:00
Damien Elmes
4e7e8b03bc moving scheduling code into separate file, some preliminary refactoring 2011-04-28 09:23:28 +09:00
Damien Elmes
7547b395ea store revlog time in integer MS
using floats for the primary key causes sqlite to generate an extra index,
which is expensive for large histories
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
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
9ce60d5e3a remove stats from graphs; use revlog 2011-04-28 09:21:07 +09:00
Damien Elmes
b837b92ef2 calculate correct counts via revlog 2011-04-28 09:21:07 +09:00
Damien Elmes
77029c4ee6 calculate # days studied using rev log instead 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
28604b9d29 remove priorities 2011-04-28 09:21:06 +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
fbae42d8ef tweak deck stats for new scheduling 2010-10-24 12:26:18 +09:00
Damien Elmes
8a28df1a80 patch from Piotr Kubowicz, fix some translations 2010-02-22 17:07:46 +09:00
Damien Elmes
e2f306ae3b fix cards/day amount 2009-11-29 19:47:53 +09:00
Damien Elmes
7d8904a65d factor spacing into due time 2009-10-01 20:17:31 +09:00
Damien Elmes
9f182b4d61 new stats 2009-10-01 17:44:43 +09:00
Damien Elmes
d96b46887e make stat formatting consistent 2009-07-18 18:09:52 +09:00
Damien Elmes
b4a330a946 add hook for deck stats 2009-07-05 16:53:12 +09:00
Damien Elmes
7612259a72 add card ease stats 2009-07-05 16:41:18 +09:00
Damien Elmes
b1f213644e tweak deck stats 2009-06-28 10:54:05 +09:00
Damien Elmes
3e2c150b17 only set lastDue if card is not new, hide due for new cards in stats 2009-06-19 07:46:26 +09:00
Damien Elmes
2d32e1aaa1 strip all chinese/japanese support out in favour of plugins 2009-06-10 22:58:28 +09:00
Damien Elmes
5cb85176e6 include all jinmei in missing/seen 2009-06-08 21:44:21 +09:00
Emilio Wuerges
d9d7fff820 fixed jinmei (reg) and jinmei (var) lists 2009-05-29 02:27:23 +09:00
Damien Elmes
bb21a0a517 update jinmeiyou and tweak formatting 2009-05-28 00:54:45 +09:00
Damien Elmes
c681159951 strip trailing whitespace, joyo->jouyou 2009-05-28 00:39:26 +09:00
Emilio Wuerges
1add5e4ca8 Added New Joyo Kanji list to kanji statistics 2009-05-28 00:31:22 +09:00
Damien Elmes
2b5f2fa896 if the time is over a minute, cap to a minute instead of assuming avg 2009-05-11 18:57:35 +09:00
Damien Elmes
ac5a92214e don't include new cards in workload calculation 2009-05-04 01:50:09 +09:00
Susanna Björverud
8d9c1cf191 Adding html comments to strings to allow them to be translated differently 2009-04-07 11:14:10 +02:00
Susanna Björverud
78265fdc24 Added back lost space in string 2009-03-30 10:43:44 +02:00
Damien Elmes
a958734f8b strip trailing whitespace and wrap lines in stats 2009-03-29 03:51:06 +09:00
Susanna Björverud
57ca74ce34 Use locale decimal point 2009-03-25 11:15:04 +01:00
Damien Elmes
a111537c26 fix refs to reviewHistory's id 2009-03-15 06:43:45 +09:00
Damien Elmes
0bff47cce9 only report kanji for models with japanese in the tags 2009-02-06 23:39:32 +09:00
Damien Elmes
4fdaa1ec79 fix stats size on osx 2009-02-06 18:56:29 +09:00
Damien Elmes
3b8df0c337 add reports for seen and non-jouyou kanji 2009-01-31 03:39:55 +09:00
Damien Elmes
ea89f1d587 show # of facts in deck stats 2009-01-27 01:48:16 +09:00
Damien Elmes
9c226d5b4f fix spacing in card stats 2009-01-05 06:14:00 +09:00
Damien Elmes
91e90d8092 card model > card template 2009-01-05 06:10:10 +09:00
Damien Elmes
cb765bcb72 deck stats should show all new cards, not just due 2008-12-17 00:41:13 +09:00
Damien Elmes
b956eff6b5 split model & card model tags 2008-12-09 02:29:08 +09:00
Damien Elmes
3dcc9c75f2 hack to make more compact table 2008-12-07 21:41:15 +09:00
Damien Elmes
1532868401 add some tags to stats 2008-12-04 02:12:42 +09:00
Damien Elmes
0e7ebae9b8 make stats smaller 2008-11-29 16:12:58 +09:00
Damien Elmes
4e937bf72a fix seen card count in kanji, fix display bug 2008-11-15 17:50:46 +09:00
Damien Elmes
af78b0bf94 fix deck stats 2008-11-15 01:11:17 +09:00
Damien Elmes
b2d0e5d3df wip 2008-11-07 18:44:49 +09:00
Damien Elmes
e25feed0af support 4am rollover 2008-10-12 04:02:33 +09:00
Damien Elmes
35fc4fbd3f track full card time, not just question. use failed cnt for average 2008-09-29 14:15:46 +09:00
Damien Elmes
5da3a0f5d3 initial commit from hg 2008-09-27 23:50:03 +09:00