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

Discussion in 'Java' started by edfialk, May 9, 2008.

  1. edfialk

    edfialk Guest

    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
    edfialk, May 9, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Cavett

    Updating Multiple Views

    Jason Cavett, Feb 9, 2007, in forum: Java
    Replies:
    1
    Views:
    438
    Daniel Pitts
    Feb 9, 2007
  2. Andy
    Replies:
    1
    Views:
    676
  3. bbmerong
    Replies:
    0
    Views:
    111
    bbmerong
    Jan 17, 2008
  4. bbmerong
    Replies:
    0
    Views:
    139
    bbmerong
    Jan 18, 2008
  5. bbmerong
    Replies:
    2
    Views:
    128
    Ken Bloom
    Jan 18, 2008
Loading...

Share This Page