Collection Hooks

I’m using this package. Is there a way to call the collection hook only after X number of documents hit the database in time Y?

For example, lets say I have a post collection. I want to execute the hook only once in a two second interval. So let’s say the user inserts 100 posts in 2 seconds, the hook will only run once. I’m facing a problem with an API call which inserts a lot of documents all at once and every time the call inserts a document, I run the hook. I know I can work around this in other ways, but I wanted to see if there was anyway to do this with the package.

You can use to run a task every x seconds. You can flag your documents as processed after they have been processed by the task.