Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Aiheen aloitti: RockAndRollBot - helmikuu 07, 2005, 01:06:20 AP

Otsikko: Topics I haven't replied to
Kirjoitti: RockAndRollBot - helmikuu 07, 2005, 01:06:20 AP
I am curious if it is possible for my users to list topics they have not replied to, in a fashion similar to listing topics they have not read.  Is this a lot of work, or is it something built in that I have just overlooked?  Thanks a lot for any help!
Otsikko: Re: Topics I haven't replied to
Kirjoitti: [Unknown] - maaliskuu 11, 2005, 06:23:27 IP
Sorry for taking so very long to respond.

No, there is currently no such feature.  Its major problem is simple: it's slow and inefficient to check for this.  Here's an example query:

SELECT DISTINCT t.ID_TOPIC
FROM main_topics AS t, main_boards AS b, main_messages AS ml
   LEFT JOIN main_log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = 2)
   LEFT JOIN main_log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = 2)
   LEFT JOIN main_messages AS m ON (m.ID_TOPIC = t.ID_TOPIC AND m.ID_MEMBER = 2)
WHERE ml.ID_MEMBER != 2
   AND ml.ID_MSG = t.ID_LAST_MSG
   AND m.ID_MSG IS NULL
   AND b.ID_BOARD = t.ID_BOARD
   AND IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) < ml.posterTime
ORDER BY ml.ID_MSG DESC
LIMIT 0, 20;

Running this here (for me) took 9.9 seconds, which is by far too long.  It would be better, if it were limited to recent topics... but, less useful.  If you want all topics, but you don't care if they're marked read or not, it's simpler:

SELECT DISTINCT t.ID_TOPIC
FROM smf_topics AS t, smf_boards AS b, smf_messages AS ml
   LEFT JOIN smf_messages AS m ON (m.ID_TOPIC = t.ID_TOPIC AND m.ID_MEMBER = 2)
WHERE ml.ID_MEMBER != 2
   AND ml.ID_MSG = t.ID_LAST_MSG
   AND m.ID_MSG IS NULL
   AND b.ID_BOARD = t.ID_BOARD
ORDER BY ml.ID_MSG DESC
LIMIT 0, 20;

This is significantly faster here, but still quite slow (3 seconds.)

-[Unknown]