How to get "Scheduled" and "Not memorized" with SQL?

26 views
Skip to first unread message

Alex .

unread,
Mar 26, 2014, 11:17:35 PM3/26/14
to mnemosyne-...@googlegroups.com
Hi,  

I am search decks for imformation about them to use outside of mnemosyne.  Can someone tell me what the proper SQL to find "Scheduled"?

I have not memorized. Its 

"SELECT COUNT(*) FROM cards WHERE active = 1 AND grade < 2;";

But I need scheduled as well..  can anyone help me?

Peter Bienstman

unread,
Mar 27, 2014, 10:35:43 AM3/27/14
to mnemosyne-...@googlegroups.com
Hi,

You need to check if 'timestamp' >=next_rep, with timestamp essentially the current time in unix format, but with some small changes to take into account timezones, etc.

If you want the nitty gritty, here is the Python function that calculates this timestamp:

def adjusted_now(self, now=None):

"""Timezone information and 'day_starts_at' will only become relevant
when the queue is built, not at schedule time, to allow for
moving to a different timezone after a card has been scheduled.
Cards are due when 'adjusted_now >= next_rep', and this function
makes sure that happens at h:00 local time (with h being
'day_starts_at').

"""

if now == None:
now = time.time()
# The larger 'day_starts_at', the later the card should become due,
# i.e. larger than 'next_card', so the more 'now' should be decreased.
now -= self.config()["day_starts_at"] * HOUR
# 'altzone' or 'timezone' contains the offset in seconds west of UTC.
# This number is positive for the US, where a card should become
# due later than in Europe, so 'now' should be decreased by this
# offset.
# As for when to use 'altzone' instead of 'timezone' if daylight
# savings time is active, this is a matter of big confusion
# among the Python developers themselves:
# http://bugs.python.org/issue7229
if time.localtime(now).tm_isdst and time.daylight:
now -= time.altzone
else:
now -= time.timezone
return int(now)

Cheers,

Peter
> --
> You received this message because you are subscribed to the Google Groups
> "mnemosyne-proj-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mnemosyne-proj-u...@googlegroups.com.
> To post to this group, send email to mnemosyne-proj-
> us...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mnemosyne-proj-users/7190d982-3fc8-
> 4578-ae63-262c68fd85db%40googlegroups.com
> <https://groups.google.com/d/msgid/mnemosyne-proj-users/7190d982-
> 3fc8-4578-ae63-
> 262c68fd85db%40googlegroups.com?utm_medium=email&utm_source=foo
> ter> .
> For more options, visit https://groups.google.com/d/optout.


Alex .

unread,
Mar 29, 2014, 1:41:01 AM3/29/14
to mnemosyne-...@googlegroups.com


Hey Ive got it so i will post it here in case anybody else needs it.

Scheduled = "SELECT COUNT(*) FROM cards WHERE active=1 AND grade>=2 AND next_rep<strftime('%s', 'now');";

Not Memorized = "SELECT COUNT(*) FROM cards WHERE active = 1 AND grade < 2;";
Reply all
Reply to author
Forward
0 new messages