Showing most popular post of week

This is not how you collect view stats over period of time. The right way to do it is to have some sort of sliding window that will help you calculate views over specific time frame.
For example to get the most popular post “today” you store the counts in an option, and zero the option every 24 hours. For the most popular in the last week, you use an option per day, remove the “oldest” one when it expires, and everyday recalculate the most popular in the last 7 days.

What your code actually does right now is to show the most popular post of those published last month, which is unlikely to be what you want.

Side note: writing to the DB on front end requests is a great way to bring a site down (you will not notice it on small site, but once you start having some good traffic… boom)…. and obviously your method will not work with page caching.