Advice on interesting reading and updating num. of views/day forobject.

E

edfialk

Hello, I'm hoping someone is intrigued and feels like conquering this.

I need to keep track of number of views per day for a particular
object. I was thinking of making it a comma separated string
("10,12,0,15,13",etc.). In addition to this field I keep track of the
last time the string was updated.

So, if the views currently are "10,12,0,15,3", the date is set to 2
days before now, and I need to update, the views would become
"1,0,10,12,0,15,3" and the date would be set to now.

1 view today, 0 yesterday, 10 the day before that, etc.

This very well might not be the best way to do it but it's the best
way I can think of right now.
I'm probably going to need to keep track of the last .... 60 days of
views.

So, time to add a new view.

First, I check how many days are recorded.
If none, set view to 1, date to now, return.
If 1, check when it was last updated.
If today, add a view and return.
Else
*Figure out some good way to count how many days ago
the date was and update accordingly.

Else if more than 1, check date, etc.

So one tough part is how many days ago was this view_date? I can get
month/day, but say it's set to 12/25 and today is 3/1. I need number
of days in each of months in between view_month and now_month (along
with checking year), subtract that from view_day, add that to now_day,
then update accordingly.

I think I can get it to work, but it'll be ugly.

So, just asking if anyone has any helpful ideas or tips that might
save me some any of my numerous if thens along the way.

Any advice would be greatly appreciated!
Thanks!

-Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top