Currently, the logic which is used to count the number of views is placed in the block code. It is causing 2 issues: Views not getting counted if block isn't placed and practically no caching for the counter block. Event subscribers would be a better way to execute the counting logic.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | Screen Recording 2021-12-02 at 9.05.51 AM.mov | 6.21 MB | lomasr |
Comments
Comment #2
sumanthkumarc commentedYes. Since if you see the code(.module file), all the queries are written in hook_block_view. Hence this gets called only when block is rendered i guess. Even i was surprised by this.
Comment #3
lomasr commentedHi,
I tested the same and found the opposite.
Created a video.
Thanks
Lomas
Comment #4
gaurav.kapoor commentedMoving to 8.x-1.x so that it is debugged and fixed in D 8/9 release as well.
Comment #5
gaurav.kapoor commentedI didn't see any issues in views getting logged but the logic of counting a view and other statistics should be moved to an event subscriber.
Comment #6
gaurav.kapoor commentedCurrently, the logic which is used to count the number of views is placed in the block code. It is causing 2 issues: Views not getting counted if block isn't placed and practically no caching for the counter block. Event subscribers would be a better way to execute the counting logic.
Comment #7
gaurav.kapoor commentedComment #9
gaurav.kapoor commentedI have moved the logic to count views to an event subscriber, will keep this issue open till all the other improvement related issues are closed.
Comment #10
gaurav.kapoor commentedComment #11
gaurav.kapoor commentedClosing this one for now as most of the coding practice improvement related issues have been fixed.