![]() |
Forum system - how to track already read vs new messages, per user - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Forum system - how to track already read vs new messages, per user (/showthread.php?tid=17292) |
Forum system - how to track already read vs new messages, per user - El Forum - 04-02-2009 [eluser]jedd[/eluser] xwero - I should learn to type faster. ![]() I like the idea of bookmarks - as a kind of flag to attach to forum threads, or even messages? As I hinted in my last message I want to look at using common tags for forum and wiki (as well as blog, articles, news, etc - who knows what I might have going on). I see these as evolutionary steps, so shall make yet another @TODO note in my code. Forum system - how to track already read vs new messages, per user - El Forum - 04-02-2009 [eluser]xwero[/eluser] As long as you are adding todos. i think the whispered conversations the vanilla forum offers are better than private messages. Then you can see the message in context. Forum system - how to track already read vs new messages, per user - El Forum - 04-02-2009 [eluser]jedd[/eluser] Okay.. that reminded me to fix up my mail handling, as I'd done some dodgy dual-use stuff with one of the fields in my 'one size fits all' message table. And I hate dodgy dual-use fields - I always forget one of the uses. I'm doing private messages as threads that have a forum ID of 0 - this is special (not keen on specials, but it'll work for now) that indicates the thread belongs to mail, not forum. I then have a separate table to denote who has access to a thread. This means I don't really need the special of '0', but will reconsider this later. The bulk of threads will not have an entry in my thread_acl table - only private messages will, and they'll require two rows (sender, receiver). This means I can possibly cater for semi-private forums & threads in the future. In any case, mail will be more forum-like, as I agree with your suggestion on this aspect. There is now no concept of an 'addressee' for a message. The addressee is effectively the other person you invite to your private thread at message compose time. Anyway, I present my current messaging schema for completeness and comments. One comment and question up front - I've separated out the message_content (4k BLOB) into its own table on the expectation I'll get better performance. Do we think that this is true? I will probably go VARCHAR on that actual message content column. I expect that I won't be hitting message very often without hitting message_content at at the same time (LEFT JOIN to grab the actual content). It's definitely a 1:1 relation, which is why I feel a bit uneasy about separating it into two tables. Code: # forum Code: # thread Code: # message Code: # message_content Code: # thread_acl Code: # message_member Forum system - how to track already read vs new messages, per user - El Forum - 04-03-2009 [eluser]xwero[/eluser] Why use a blob for text? Forum system - how to track already read vs new messages, per user - El Forum - 04-03-2009 [eluser]jedd[/eluser] Fixed. If that was the only problem you could find, I'm cracking this dodgy bottle of Peruvian red and starting Saturday early. Forum system - how to track already read vs new messages, per user - El Forum - 04-03-2009 [eluser]TheFuzzy0ne[/eluser] OK, I've been thinking. Hopefully I'm on the right track here, because the last two pages of this thread have confused the bejesus out of me... I still think a library should exist for this reason. The only problem I can see, is that the library would have to be aware of the forum structure to some extent, in order to mark child forums as being read. To facilitate this, I think the library can contain functions that need to be overridden in order to return the data necessary. For example: Code: function get_child_forums($forum_id=0) And in case it's not already clear, the library will actually be a model, and the forum model should extend this model. Basically, the user is able to describe their forum structure to the library. Now, I know I need to think this through a lot more, and perhaps have the forum structure represented by an array or something, but I think this is the key to creating a portable library - by bridging the gap between the library and the users' set-up. Forum system - how to track already read vs new messages, per user - El Forum - 09-04-2009 [eluser]TheFuzzy0ne[/eluser] Hi, everyone. I've spent several months working on the most efficient way to track read posts, but I still can't figure it out... xweros idea is pretty flawless, however, where I'm stuck, is when it comes to displaying the actual forums which contain posts that have not been read. I have no idea on the most database efficient method to show when a forum contains unread topics/posts. I'd appreciate any input anyone may have to offer. I used to have a full head of hair, and to say it's thinning out a bit is putting it mildly. Many thanks in advance. Forum system - how to track already read vs new messages, per user - El Forum - 09-04-2009 [eluser]jedd[/eluser] Similarly, I have no idea if I've done this in the most database-efficient way (and I'll defend the query-within-a-loop below as it was proof of concept stuff that I haven't gone back to optimise yet! ![]() Code: // message() model extract ... Forum system - how to track already read vs new messages, per user - El Forum - 09-04-2009 [eluser]jedd[/eluser] To track where a user is up to in a thread, I use this table: Code: # NOTE: only ever one row for any given [ thread_id , member_id ] pairing. The table above is what is referred to in the get_last_read_message_in_thread() function in the previous post. Sorry I had to split things up after the forums got confused about the message length. In my forum controller, well, the previous message's stuff is called from the /forum/threads/ method, but when I start to actually read messages, I have this bit in the messages controller to update the 'last read message' info: Code: // extract from forum controller, message() method I reasoned it was more sensible to control this update from the controller, partly because of the complexity introduced by pagination, and the fact that my model functions might not always be doing their calls for the current logged-in user. Of course, you can grab full source on that URL I mentioned earlier if you want more context. I'm also thinking that whenever a user goes to read a thread that is older (most recent message's age) than a given age - probably 1 month - it'll lock that thread. Thread-locking will involve going through the above table and rows with that thread #. Periodic cron-style jobs can be run to catch everything else. Any thread that is locked will appear as read (the default case). Any thread that isn't locked, and does not appear in this table, will be considered to be unread / new. Thread-watching is something else entirely, and I made a mistake early of trying to hybridise the two features. I had a 'watched' flag in the above table, and just took it out as I think of it as a throwback, but I'm still actually undecided on how to handle watched threads that are locked. For storage reasons, it makes sense to cull them. But it's a trivial amount of space, I guess, and a later-unlocked thread would be of interest to any ex-watchers ... arguably. In any case, watching is a separate function. So, how far is all this from being useful to you? ![]() Forum system - how to track already read vs new messages, per user - El Forum - 09-05-2009 [eluser]TheFuzzy0ne[/eluser] Thanks for your input, Jedd. Unfortunately, I'm not quite sure how this ties in with my original question. I've been looking at PHPBBs code, but I just can't seem to figure out what it's doing and how. As I mentioned, tracking the posts is not the problem; the problem is how I can efficiently indicate that the forum "container" contains unread threads. Also, this needs to take into account any subforums, too. I hope this makes a bit more sense. I regret that I am not as well versed in the English language as you clearly are. ![]() |