cyrildewit / eloquent-viewable

Associate views with Eloquent models in Laravel
MIT License
803 stars 104 forks source link

Help: Help for triggering the record function in Queue #255

Closed hasnat-we closed 2 years ago

hasnat-we commented 3 years ago

Thanks a lot for this plugin. I was trying to fire the record method in a Queue job like below in Controller. EloquentViewableVisitLogger::dispatchAfterResponse($post);

It increase the view record nicely but the cooldown is not working as expected since session is missing from Queue environment. So the views count is increasing for each visit and page load.

Can you please give me a suggestion, is there any way to make cooldown work in Queue environment? Thanks in advance.

cyrildewit commented 3 years ago

This is a known limitation of the design. The session check should be done before adding the job to the queue, but since this logic is tightly coupled to the implementation, there is currently no way to do this beforehand. If you've any ideas to improve the design, please let me know.

For your information, I'm currently not actively adding new features or making improvements. I do accept contributions and I'm open to discussing new ideas. In the future when I have more time, I will probably do an iteration again to fix some of these problems.