How to get card review history, particularly, leech count?

I have two different ideas in mind but I think they need overlapping data. Would appreciate any pointers, I have worked on add ons before but never information from the scheduler.

One piece of information is how many times a card has been labeled as a leech. I’m not sure if this is directly retrievable, or has to be recalculated based on the review history. I’m fine recalculating, but then I need he review history, which I’m not sure how to get.

The other piece of information I want is what a card’s review status was every day since it’s creation…basically, for every day, was it new? Young? Learning? Mature? Maybe this also can also be calculated from the review history, or information on state transitions? Like I said, I haven’t worked with this information in Anki at all so don’t really know how to get at it.

Would appreciate any pointers! where in the Anki source to look, or any add ons that get at similar data so I can see how they do it. Of course if anyone knows the data model for this stuff well and can let me know if the above two things are reasonable, it’d be a huge help. Thank you!

This code would be related: