Open TreyWW opened 6 months ago
(converting to draft as I have not yet been able to run the tests, I'll try again when I get home just to make sure it passes and works fine)
Hi @jsocol,
I have added the increment_ratelimit
function in the core file. I have also included a new test (test_increment_ratelimit) and added some documentation for this addition as well.
I hope this is what you was looking for, if there's anything I can change to make it better let me know!
Thanks
Note: I couldn't manage to get it to work without the rate, method and key so I've left them in. My original idea was to not have to use any of them though - so is this still okay? The only difference between this and "is_ratelimited" is that increment is true by default and it has a better name.
I added an
increment_ratelimit
function to just increment the group ratelimit count. This is practically just an alias ofis_ratelimited
but makes more sense in terms of its name. Takes only request and group (should I add keys, and fn too?) and returns the count of limits on return (can be a boolean True if successful instead if preferred). This was suggested in #308 as it makes more logical sense to call a function to "increment" the ratelimit rather than call "is_ratelimited" if you're just incrementing it.Where would this be useful? Well in situations like unsuccessful login attempts, in the logic for your function you may want to add 1 to the count (in this case you dont use decorators), so you need to call a function.
This snippet makes a little more sense then this snippet (logically)
Closes issue: #308