ankidroid/Anki-Android — pull request #361 by chajadan (2014-05-15 10:51:12+00:00)
Title: Enable total new count on deck front page.

This change allows the user to see the actual number of new cards in a deck on the deck intro page. If a truncated result is received (currently capped at 1000), a thread is spawned that gets the actual total and updates the UI -- that way if this process is slow for some reason the user can either wait for the UI to update if they care, or they can simply move on and not notice if they don't care.

There are 2 TODO: comments in this code. In both cases, modifying Sched.java would have been the most elegant solution, but I've been made paranoid about introducing changes to libanki. I've added code comments to mention what I would have liked to do.

I'm about to make a pull request to anki however to change their query to the version I use in this thread. You asked for "a cool fast sql query" @nicolas-raoul so, this might it assuming sqlite wasn't able to optimize out the unnecessary subquery.