I'm working on an application that has similar logic as SO with regards to when the user was last seen. I've run into a conceptual problem that I'm hoping some of you Guru's can help me out with.
All activity is logged in an ActivityLog table in the database
When a logged in user hits the site and a new session is created, I update the activity log with the UserID and some very generic info. Same thing happens when they create a new record, update their profile, etc.
The problem I'm having is this.
If I use the most recent activity item, then navigate to my personal account page, the "Last Seen" shows up as 1 second ago because I JUST hit the db on session start... This is not good because I want to see what I was "last" there, not when I'm there "now".
However, if I use Skip(1).Take(1)
to get the second record in the database, then when someone else views my profile while I may have "just" signed on... they'll see that I was on say a week ago and not today.
What kind of logic would you use in order to have your cake and eat it too?
I'm using ASP.NET MVC2 and Linq to SQL, but I think this question is more language agnostic.
current
andlast
in the user table as well as retain an activity log? This sounds like more work overall since I have to maintain two record locations. I'm using the activity log for other things as well, so I don't want to remove it. – Manzano