Help creating a simple add-on

Hi,

I do have some questions.

I guess now that is not possible to use monkey patching if the original code is no longer in Python but Rust, right? The way to go are hooks I suppose.

I want to make a really simple add-on. When reviewing, the bottom counts new learning due
Untitled
to change it so it’s shown as new learningCount (learningReviewCount) relearningCount(relearningReviewCount) due. Hopefully coloring purple the relearning counts.

What I do not know is which hook do I have to use for that matter. Can someone give me a hint where to look at?

the remaining cards stats are done in reviewer.py, specifically in the _remaining() function. You probably have to resort to monkey patching as there does not seem to be any hook for it.

3 Likes

Thank you for pointing that out,

finally made the add-on. I relied on doing my own sql queries rather than using built-in methods, as I only get 3 stats out of 6. The bad news is that those queries are executed at each review and roughly takes half a second. That outweights the benefit of getting the data I want to be displayed.

2 Likes

Half a second seems too much. Maybe you could post the queries, there could be room for improvement.

1 Like

It is based in Deck Counts Now/Later add-on

select
	--learn Reps
	sum(case when queue=1 then left/1000 else 0 end),
	--relarn Reps
	sum(case when queue=3 then left/1000 else 0 end),
	--learn Cards
	sum(case when queue=1 then 1 else 0 end),
	--relearn cards
	sum(case when queue=3 then 1 else 0 end)

    from cards where did=?

You could experiment with separate queries with “where did=? and queue=1” and "“where did=? and queue=3”, as that may better take advantage of the ix_cards_sched index.

It does not makes much of a difference. I did not measured the time, but the wait is above my subjective tolerance. I guess it is due the size of the deck. In a small 4k card deck I do not feel any delay, and in such small decks I won’t need the add-on.