From {T270318}, getting an accurate count for the number of past blocks for an IP is more complicated than originally expected:
>>! In T270318#7377014, @phuedx wrote:
> https://gerrit.wikimedia.org/r/723530 introduces the `BlockManager::getIPBlock()` method, which gets blocks that apply to the given IP address, including system blocks.
>
> * You can't query the `logging` table by IP range whereas you can the `ip_blocks` table. However, the `ip_blocks` table isn't always guaranteed to be exhaustive as expired blocks could be purged by running the `maintenance/purgeExpiredBlocks.php` script in MediaWiki Core [and are purged whenever a new block is inserted into the database]
==== Questions
1. How could we keep an accurate record of the number of past blocks affecting an IP
==== Notes
1. We could use [[ https://www.mediawiki.org/wiki/Manual:Ip_changes_table | the ip_changes table ]] as inspiration – it's a table created to return very specific information for an IP or a range of IPs.
2. Could/we should create a hook that fires whenever a block is inserted into the database?