Code Monkey home page Code Monkey logo

Comments (18)

ewnd9 avatar ewnd9 commented on May 29, 2024 1

I reopened because I want to implement the random mock #11 (comment)

Hope you will leave a note here on a dialog with the Anki developers

from anki-apkg-export.

ewnd9 avatar ewnd9 commented on May 29, 2024 1

It's not ready to be closed, context: #14 (comment)

from anki-apkg-export.

ewnd9 avatar ewnd9 commented on May 29, 2024

What about removing random generation / new Date during work? It makes harder to compare values and give no pros. We can just have incremented counter for each deck

That's a good question 👍 Got me thinking that we can simply mock Date and Math.random entirely. E.g. Run once and log every randomly generated value in tests, write an archive to the fixtures directory, then insert it as mocks.

P.S. just note - why export when class import data into Anki deck?

Exporting data from JavaScript to an Anki apkg format archive.

from anki-apkg-export.

vvscode avatar vvscode commented on May 29, 2024

Is there any pros from random data inside exporter? We create each deck from scratch. So we can iterate from 1 up to. And it allow sort cards by import order ( right know we can't do it )

Also if in future we'll add ability to work with existing collections ( add new cards to existing decks ) random numbers can make a bad joke

from anki-apkg-export.

ewnd9 avatar ewnd9 commented on May 29, 2024

Is there any pros from random data inside exporter?

It's in the spec (http://decks.wikia.com/wiki/Anki_APKG_format_documentation)

allow sort cards by import order ( right know we can't do it )

If it is missing in the spec, it's meaningless in a case of existing apps. Elaborate where do you want to sort cards, please.

Also if in future we'll add ability to work with existing collections

I have a separate module in mind for import (haven't tested yet) https://github.com/davidey/anki-to-json

from anki-apkg-export.

vvscode avatar vvscode commented on May 29, 2024

it says random but I can even imagine cases which not covered with incremented values

from anki-apkg-export.

ewnd9 avatar ewnd9 commented on May 29, 2024

Elaborate where / why do you want to sort cards, please.

from anki-apkg-export.

vvscode avatar vvscode commented on May 29, 2024

https://github.com/ewnd9/anki-apkg-export/blob/d272b9290eb66489fa0a3bf896cb39e6db667ec3/test/test.js#L90 for example

also using random potentialy can generate conflict with identical ids for different rows

from anki-apkg-export.

ewnd9 avatar ewnd9 commented on May 29, 2024

Do you think this is a shared problem between every Anki client / implementation?

from anki-apkg-export.

vvscode avatar vvscode commented on May 29, 2024

not sure. I'm as user never think about ids. But as for developer - using random numbers is strange

from anki-apkg-export.

ewnd9 avatar ewnd9 commented on May 29, 2024

I recommend reaching Anki developers for discussing the purpose of random in DB or maintaining your own fork because I'm not intended to deviate from the spec.

from anki-apkg-export.

vvscode avatar vvscode commented on May 29, 2024

I understand. Maybe you can share link to main repo? Is it https://github.com/dae/anki ?

from anki-apkg-export.

ewnd9 avatar ewnd9 commented on May 29, 2024

Yes

from anki-apkg-export.

vvscode avatar vvscode commented on May 29, 2024

https://anki.tenderapp.com/discussions/add-ons/8620-information-about-database-structuredetails

from anki-apkg-export.

vvscode avatar vvscode commented on May 29, 2024

and using random doesn't provide uniq

from anki-apkg-export.

ewnd9 avatar ewnd9 commented on May 29, 2024

Spec was a lie 😳

I made a little source code research, both the original Anki app and Ankidroid use timestamp + in loop increment for uniqueness, so a pull request to recreate a similar behavior is welcomed.

anki:

https://github.com/dae/anki/blob/24b451b0e4cfb50191e294052363a79f69f35c02/anki/notes.py#L17
https://github.com/dae/anki/blob/24b451b0e4cfb50191e294052363a79f69f35c02/anki/utils.py#L193-L200

ankidroid:

https://github.com/ankidroid/Anki-Android/blob/a6b58f2fc9a8fbf686fe6eaf2a42b76ed5d9a84f/AnkiDroid/src/main/java/com/ichi2/libanki/Note.java#L71
https://github.com/ankidroid/Anki-Android/blob/a6b58f2fc9a8fbf686fe6eaf2a42b76ed5d9a84f/AnkiDroid/src/main/java/com/ichi2/libanki/Utils.java#L385-L393

Also db structure description
https://github.com/ankidroid/Anki-Android/wiki/Database-Structure

wiki spec (random, lie)
http://decks.wikia.com/wiki/Anki_APKG_format_documentation

ruby (uses random)
https://github.com/albertzak/anki2/blob/master/lib/anki2.rb#L33

from anki-apkg-export.

vvscode avatar vvscode commented on May 29, 2024

Ok, thx

But using timestamp still confuse me, use increment is more habitual ( for me at least ) and covers the same limitation. But I'll create PR with the same behavior

from anki-apkg-export.

vvscode avatar vvscode commented on May 29, 2024

#15

from anki-apkg-export.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.