Skip to content

Instantly share code, notes, and snippets.

@knewter
Created April 9, 2012 14:55
Show Gist options
  • Save knewter/2344034 to your computer and use it in GitHub Desktop.
Save knewter/2344034 to your computer and use it in GitHub Desktop.
incorrect first effort at SRS algorithm (this one just gets cards that haven't been answered longest first)
#I'm implementing a flashcard learning system. I have cards and answers. I want a SQL query that will return the card that has been answered longest ago (so if you've not answered a card in a long time, you should be more likely to see it)
SELECT DISTINCT "cards".id FROM "cards" LEFT OUTER JOIN "answers" ON "answers"."card_id" = "cards"."id" LEFT OUTER JOIN "decks" ON "decks"."id" = "cards"."deck_id" WHERE (deck_id = 1) ORDER BY answers.created_at ASC LIMIT 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment