At some point in the past, I decided I needed some general-purpose code that would help me save to the database and, in turn, retrieve view counts for all time as well as for any time or date range. Now, however, I have been gripped by a website speed-up mania again, so my attention turned to this component. Over time it has learned, for example, to save to the DB only when the address has parameters with values of the correct types, or to save to a table with the ID of the logged-in user.
Now I have created tables for about the 7 most frequently saved pages, and instead of the page name and the URI parameters I store only the ID of the given entity in these tables (for example, for a photo, the ID of the photo in the database). This makes finding out the view count much simpler. The total view count is updated every time the page loads, while the view count for the last 7 days is updated every day at the start of the day, so it can effectively lag up to 24h behind.
The reason is that I do not want to update the view counts for the last x days on every page visit, which would not help my speed much. Along with this, I created a new page where you can see the most interesting posts on the CasdMladez website .
However, because I deleted references to the pages that now live in the new tables from the old tables, comments do not work on these pages. So I have to rework these comments, and that is the next thing I am already getting to.