Commit graph

48 commits

Author SHA1 Message Date
Damien Elmes
2dfdfad6f2 update license link 2011-04-28 09:24:01 +09:00
Damien Elmes
8fcc6b3085 gpl3->agpl 2011-04-28 09:24:01 +09:00
Damien Elmes
ccc325f87b remove utcOffset; make it a property of crt instead 2011-04-28 09:23:56 +09:00
Damien Elmes
511d6e89a1 remove progress handling code; we'll do it in the GUI or provide cb 2011-04-28 09:23:55 +09:00
Damien Elmes
64bd1dc06a remove some old references in exporting; no attempt to update it yet 2011-04-28 09:23:55 +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
2d1d946504 refactor media
- created->modified
- size->refcnt
- originalPath->chksum
- remove description
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
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
f3a336a4e4 when exporting a standard anki deck, don't put media in dropbox 2011-02-03 00:14:36 +09:00
Damien Elmes
b8e19d5506 don't copy media on export if disabled 2011-02-03 00:10:40 +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
be4dea39b1 more scheduler updates
- reimplement reviewEarly and newEarly by replacing parts of the scheduler,
  instead of adding special conditions
- remove references to isDue and priority (1,2,3,4) which is not necessary
  anymore
- add option to switch between per-day scheduling and due now scheduling
- newCardsToday() -> newCardsDoneToday()
- don't decrement counts for suspended cards
- make sure to update type when suspending/unsuspending
- fix findCards()
- set hardInterval = 1-1.1 on upgrade, or the default per day scheduling doesn't
  make sense
2010-10-18 18:01:19 +09:00
Damien Elmes
b8401eff22 ignore parse errors due to invalid html on export 2010-06-28 11:52:25 +09:00
Damien Elmes
af66630f07 delay beautifulsoup import until export 2010-04-01 22:57:26 +09:00
Damien Elmes
715c82aba9 remove debugging line in exporting 2010-02-09 01:31:05 +09:00
Damien Elmes
582a9dd290 don't create empty tags on export 2010-02-05 12:27:32 +09:00
Damien Elmes
187caa874b make sure to remove deck if exists before exporting into it 2010-02-02 00:28:15 +09:00
Damien Elmes
c90828349c remove obsolete reference to card tags, don't store card tags on import 2010-01-23 10:59:40 +09:00
Damien Elmes
ea2fa24fed add progress info to card/fact export 2010-01-23 10:51:02 +09:00
Damien Elmes
b4f1d6622a use html parser on text export instead of fragile regex 2010-01-23 08:13:43 +09:00
Damien Elmes
e1c3cc7b5c honour card/fact creation order when exporting as text 2009-06-29 23:26:35 +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
423974934c unify decks/deck -> Deck, fix & build translatations 2009-05-21 01:04:15 +09:00
Damien Elmes
ea9ad13932 add support for alternative media dir and disabling media copy on export 2009-05-16 04:07:54 +09:00
Damien Elmes
d09709fb50 use tag cache for great speed increase in cram, allow card id limit 2009-04-06 12:16:09 +09:00
Damien Elmes
5ca9afa0da update priorities on export 2009-03-29 11:53:44 +09:00
Damien Elmes
1be887872d use utc offset of -1 instead 2009-03-21 03:55:24 +09:00
Damien Elmes
cfc458e45f fix exporting re 2009-01-17 22:45:00 +09:00
Damien Elmes
f636b71b8c strip field model html on text card export 2009-01-17 17:37:07 +09:00
Damien Elmes
334d126237 recording & noise profile support on linux 2009-01-17 01:05:39 +09:00
Damien Elmes
6015dbec04 add progress to export, speed up export, tweak undo progress 2009-01-16 19:23:23 +09:00
Damien Elmes
9d3fb8d922 make sure to delete stats on export 2008-12-13 13:46:01 +09:00
Damien Elmes
de2780e797 record exported card count when exporting anki deck 2008-11-23 09:18:41 +09:00
Damien Elmes
e1d3f791f5 do need to rebuild counts on export 2008-11-21 15:46:17 +09:00
Damien Elmes
de09e37006 no need to rebuild count on export, as it's done in sync 2008-11-17 08:30:14 +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
6d358c9166 delete from review history on export 2008-10-19 03:05:43 +09:00
Damien Elmes
c0e5bed6a6 sync sources, support media syncing in import/export again 2008-10-18 20:20:43 +09:00
Damien Elmes
0d87b6f32d set timeout to 10 seconds on sync 2008-10-11 18:19:18 +09:00
Damien Elmes
5da3a0f5d3 initial commit from hg 2008-09-27 23:50:03 +09:00