Commit graph

32 commits

Author SHA1 Message Date
Damien Elmes
2616e95348 don't delete old revlog entries when cards deleted 2012-07-11 10:35:17 +09:00
Damien Elmes
07ae142781 we don't automatically delete anymore, so update unit test 2012-06-19 16:35:56 +09:00
Damien Elmes
74bd61139a fix unit test 2012-04-19 11:42:56 +09:00
Damien Elmes
609e165c95 use deck of existing cards if all use same deck 2012-04-18 05:24:02 +09:00
Damien Elmes
35a10744a6 'open' was a silly choice 2011-12-12 02:25:16 +09:00
Damien Elmes
0b96e8a1a9 per-fact empty card deletion, and delete hook 2011-12-11 23:48:24 +09:00
Damien Elmes
8be0e6cccd make sure we add + delete cards after template changes 2011-12-11 23:35:59 +09:00
Damien Elmes
b5c0b1f2c7 drop required/unique field properties
Instead of having required and unique flags for every field, enforce both
requirements on the first field, and neither on the rest. This mirrors the
subject/body format people are used to in note-taking apps. The subject
defines the object being learnt, and the remaining fields represent properties
of that object.

In the past, duplicate checking served two purposes: it quickly notified the
user that they're entering the same fact twice, and it notified the user if
they'd accidentally mistyped a secondary field. The former behaviour is
important for avoiding wasted effort, and so it should be done in real time.
The latter behaviour is not essential however - a typo is not wasted effort,
and it could be fixed in a periodic 'find duplicates' function. Given that
some users ended up with sluggish decks due to the overhead a large number of
facts * a large number of unique fields caused, this seems like a change for
the better.

This also means Anki will let you add notes as long as as the first field has
been filled out. Again, this is not a big deal: Anki is still checking to make
sure one or more cards will be generated, and the user can easily add any
missing fields later.

As a bonus, this change simplifies field configuration somewhat. As the card
layout and field dialogs are a popular point of confusion, the more they can
be simplified, the better.
2011-11-24 22:16:03 +09:00
Damien Elmes
6e4e8249fb facts -> notes 2011-11-23 12:37:21 +09:00
Damien Elmes
7a5cee1d20 remove remaining CSS; more template properties into div 2011-11-18 08:25:56 +09:00
Damien Elmes
795cdd7d3f remove the concept of non-active templates
The old template handling was too complicated, and generated frequent
questions on the forums. By dropping non-active templates we can do away with
the generate cards function, and advanced users can simulate the old behaviour
by using conditional field templates.
2011-11-08 18:06:19 +09:00
Damien Elmes
46dd863f3c convert genCards() to bulk update; drop random 2011-10-22 03:39:34 +09:00
Damien Elmes
de8a5b69ed top level groups
As discussed on the forums, moving to a single collection requires moving some
deck-level configuration into groups so users can have different settings like
new cards/day for each top level item.

Also:
- store id in groups
- add mod time to gconf updates
- move the limiting code that's not specific to scheduling into groups.py
- store the current model id per top level group
2011-09-07 01:31:46 +09:00
Damien Elmes
6a00419ebc merge deck.qconf and deck.conf 2011-08-28 14:17:33 +09:00
Damien Elmes
a9b4285959 rename a few methods for consistency 2011-08-28 13:48:17 +09:00
Damien Elmes
d3a3edb707 move models into the deck table
Like the previous change, models have been moved from a separate DB table to
an entry in the deck. We need them for many operations including reviewing,
and it's easier to keep them in memory than half on disk with a cache that
gets cleared every time we .reset(). This means they are easily serialized as
well - previously they were part Python and part JSON, which made access
confusing.

Because the data is all pulled from JSON now, the instance methods have been
moved to the model registry. Eg:
  model.addField(...) -> deck.models.addField(model, ...).

- IDs are now timestamped as with groups et al.

- The data field for plugins was also removed. Config info can be added to
  deck.conf; larger data should be stored externally.

- Upgrading needs to be updated for the new model structure.

- HexifyID() now accepts strings as well, as our IDs get converted to strings
  in the serialization process.
2011-08-27 22:27:09 +09:00
Damien Elmes
47be8b0546 use the timestamps instead of forcing id on fact/card creation
- we ditch nextCid/nextFid as we don't need incrementing ids anymore
- we add nextPos so we can maintain a user-friendly position number
2011-08-27 00:36:39 +09:00
Damien Elmes
644a885a07 update fact ids, graves
- should never skip recording graves, for the sake of merging
- 1.0 upgrade will fail on decks that have the same fact creation date. need
      to work around this in the future
2011-08-26 21:23:16 +09:00
Damien Elmes
6644c04852 start work on id refactor - models first
The approach of using incrementing id numbers works for syncing if we assume
the server is canonical and all other clients rewrite their ids as necessary,
but upon reflection it is not sufficient for merging decks in general, as we
have no way of knowing whether objects with the same id are actually the same
or not. So we need some way of uniquely identifying the object.

One approach would be to go back to Anki 1.0's random 64bit numbers, but as
outlined in a previous commit such large numbers can't be handled easy in some
languages like Javascript, and they tend to be fragmented on disk which
impacts performance. It's much better if we can keep content added at the same
time in the same place on disk, so that operations like syncing which are mainly
interested in newly added content can run faster.

Another approach is to add a separate column containing the unique id, which
is what Mnemosyne 2.0 will be doing. Unfortunately it means adding an index
for that column, leading to slower inserts and larger deck files. And if the
current sequential ids are kept, a bunch of code needs to be kept to ensure ids
don't conflict when merging.

To address the above, the plan is to use a millisecond timestamp as the id.
This ensures disk order reflects creation order, allows us to merge the id and
crt columns, avoids the need for a separate index, and saves us from worrying
about rewriting ids. There is of course a small chance that the objects to be
merged were created at exactly the same time, but this is extremely unlikely.

This commit changes models. Other objects will follow.
2011-08-26 21:08:30 +09:00
Damien Elmes
0af03a6a8a only use deletion log when necessary 2011-05-07 21:45:55 +09:00
Damien Elmes
3d370f675b restore the deletion log
the initial plan was to zero the creation time and leave the cards/facts there
until we have a chance to garbage collect them on a schema change, but such an
approach won't work with deck subscriptions
2011-05-04 19:00:38 +09:00
Damien Elmes
974324e3dd add unit test for order 2011-04-28 09:24:04 +09:00
Damien Elmes
13a484ea36 allow user to abort schema mod 2011-04-28 09:24:02 +09:00
Damien Elmes
1d91e459ec wrap the q/a in the card template div 2011-04-28 09:23:57 +09:00
Damien Elmes
9d52196949 add a bgclass helper func 2011-04-28 09:23:57 +09:00
Damien Elmes
31a548ee42 add a dirty flag
when we make changes that need to be cleaned up on exit, we mark the deck
dirty so that if we exit without saving, we can clean up on next open
2011-04-28 09:23:57 +09:00
Damien Elmes
ccc325f87b remove utcOffset; make it a property of crt instead 2011-04-28 09:23:56 +09:00
Damien Elmes
f9c3b27e5d give facts a group, so that cards can have their group reset if necessary 2011-04-28 09:23:55 +09:00
Damien Elmes
e728d49232 delete -> del for consistency 2011-04-28 09:23:55 +09:00
Damien Elmes
1dc3a0ad4a make sure revlog is removed on immediate delete 2011-04-28 09:23:55 +09:00
Damien Elmes
f96a495b53 fact.model -> fact.model() 2011-04-28 09:23:54 +09:00
Damien Elmes
870c80e076 add genCards(), previewCards(), and more unit tests 2011-04-28 09:23:54 +09:00