The "Last Seen" column currently sorts by the "changed" timestamp found in the "users" table. However, this doesn't always accurately reflect when a user last visited a site. This patch modifies the module so last seen gets sorted by the last time the user viewed a page, as logged by the statistics module.

This module will work with or without the statistics module enabled. If statistics module is disabled, the module will continue to work as before.

IMPORTANT: If you install this module over an existing installation, you must change/reset the module's settings to display the "lastseen" column.

CommentFileSizeAuthor
members.patch2.82 KBSteve Dondley

Comments

Steve Dondley’s picture

I've discovered this code doesn't scale to well with a large access log table. Please let me know if you have any ideas on how to make the code more efficient.

walkah’s picture

not sure that it would scale *that* much better... but the timestamp on the session might be a better bet (i.e. this is what the "who's online" block uses as well.

does that sound better?

Steve Dondley’s picture

I'm not sure how the sessions table exactly works, but looking at the data, it doesn't appear to keep records for very long. They seem to get deleted after a certain amount of time.

Steve Dondley’s picture

I will be uploading a patch shortly that simply does a query for each user. While it's counterintuitive, it actually runs much quicker than the single query used in the patch.

neablo’s picture

how do i force the members module to sort the members by "last seen" and not by "roles" ?

junyor’s picture

Wouldn't it make sense to fix the 'changed' date in Core rather than hacking around this here?

junyor’s picture

Version: 4.6.x-1.x-dev » master
Status: Needs review » Closed (duplicate)

I think 4.7 solves the "last seen" issue by changing the column in the users table to "access" rather than "changed". Furthermore, http://drupal.org/node/66532 fixes this problem for 4.7.