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.
0.70, introduces a unique 'My Contacts Except' choice to the 'Last Seen' section of the app's privacy controls. To utilize the function, go to settings > privacy > Last seen > My Contact list, and enter the names you want to add from whom you want to hide your 'last seen' status."
What is stack overflow? A stack overflow is a type of buffer overflow error that occurs when a computer program tries to use more memory space in the call stack than has been allocated to that stack.
It sounds like you could just show the second most recent record for the current user, and for all other users show the most recent one.
What I would do (simply to avoid a large logic loop) would be to add two fields. current_seen
and last_seen
. On login move current_seen
to last_seen
and set current_seen
to the current timestampe. Then display last_seen
as their "Last seen on XX/XX/XXX".
One place to look is at the source code to OSQA (the open source q&a system) -
http://www.osqa.net/
And yes, it looks a lot like StackOverflow (to say the least).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With