0

The recently active list for admins and mods (team) appears broken, at least regarding myself. Currently it says I was last active 4 days ago, yet I've been on and active every day for the last 4 days (including posting and admin duties - the infractions list even shows my last infraction given 2 days ago for example).

Odd...

Edited by happygeek

3
Contributors
10
Replies
127
Views
1 Year
Discussion Span
Last Post by Dani
0

And, of course, it now seems to have caught up with itself and has me down as being active a few minutes ago. Looks like admin/moderating activity didn't do anything, nor did replying to posts, but creating a new thread did.

Still odd... :-)

0

If it helps, at the start of yesterday it was saying I was last active 2 days ago - which then caught up and reported things correctly - and this morning it's now saying 3 days ago :)

0

I get that the cron jobs are most likely buggy, but I can't seem to figure out where the bug is.

There is a members table in the database, that we can assume has columns id and last_visit_timestamp. There is an articles_read table that records the articles read by each member, with columns member_id, article_id and timestamp. There is a forums_read table that records forums explicitely marked as read, with columns member_id, forum_id, and timestamp.

What am I doing wrong in this cron job that runs every couple of hours??

UPDATE members
SET members.last_visit_timestamp =
GREATEST(
    COALESCE((
        SELECT MAX(articles_read.timestamp)
        FROM articles_read
        WHERE articles_read.member_id = members.id
    ), members.last_visit_timestamp),
    COALESCE((
        SELECT MAX(forums_read.timestamp)
        FROM forums_read
        WHERE forums_read.member_id = members.id
    ), members.last_visit_timestamp)
)
0

Would it be clearer to use this SQL instead?

UPDATE members INNER JOIN articles_read
ON members.member_id = articles_read.member_id AND
   members.last_visit_timestamp < articles_read.timestamp
SET members.last_visit_timestamp = articles_read.timestamp;

UPDATE members INNER JOIN forums_read
ON members.member_id = forums_read.member_id AND
   members.last_visit_timestamp < forums_read.timestamp
SET members.last_visit_timestamp = forums_read.timestamp;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.