| [ Main Page ][ First New ] |
|
Posted by Krux
on Thursday October 7, 2010 @ 05:31pm >> [ reply ][ rating +0 ] So looks like I need to work on another major fix to thcnet. As of PHP 5.3 the ereg function no longer exists, and thcnet makes heavy use of that. Have to update everything to the PCRE compatible regular expressions when I get the chance. "There's a good chance that you might be stupid." |
|
|
|
Posted by Krux
on Sunday October 10, 2010 @ 05:45pm >> [ reply ][ rating +0 ] Why did they dump ereg()? Because preg is better. I've been going through my code and fixing things on the development site. "There's a long-standing bug relating to the x86 architecture that allows you to install Windows." -- Matthew D. Fuller |
|
Posted by Caliber
on Thursday October 7, 2010 @ 10:02pm >> [ reply ][ rating +0 ] So looks like I need to work on another major fix to thcnet. As of PHP 5.3 the ereg function no longer exists, and thcnet makes heavy use of that. Have to update everything to the PCRE compatible regular expressions when I get the chance. neat, except it isn't... that sucks man $1500 keyboards are dumb. --voltaic |
|
Posted by kodrik
on Sunday September 26, 2010 @ 04:46pm >> [ reply ][ rating +0 ] What I had done with forum type modules is add three fields to each messages, one that holds the id of the top thread (ancestorid=ancid), one that holds the order of the post (ordre in french since order is reserved) and one that holds the level (for the padding). It gets recalculated every time a post is added with a function that uses the recursive code you use now as a user can wait longer on a save than on display and it doesn't happen many times. You should be able to add it to thcnet without changing much and your display will happen very fast. You can then display all the posts in a thread with just one query: "select * from forum where ancid='$ancid' order by ordre asc" Messages will be returned in order and you can use the level field to control the padding-left. It will make it very fast to display any thread without recursive queries. You won't need to change the structure of thcnet and it will still work the old way so you can optimize different areas over time as long as you have that function wherever a post is added or deleted. I would not wish to a dog or to a snake, to the most low and misfortunate creature of the earth-I would not wish to any of them what I have had to suffer for things that I am not guilty of [...]; but I am so convinced to be right that if you could execute me two times, and if I could be reborn two other times, I would live again to do what I have done already.~Bartolomeo Vanzetti |
|
Posted by voltaic
on Tuesday September 28, 2010 @ 07:36am >> [ reply ][ rating +0 ] I liked that design when you first came up with it way back in the day Kodrik, but the only problem is it doesn't have the flexibility to change into another view on the fly. For example, if you have a user who wants nested messages compared to one who prefers a linear presentation like in vBulletin. Maybe not a big deal 10 years ago, but now with mobile devices, linear presentations are many times preferred because they take up less real estate horizontally (indenting). It is also more difficult to come up with a "new posts first" strategy. Well actually neither of these are difficult per se, but they defeat the purpose of the work you put into building the structure into the DB. "That dude has the world's biggest forehead... great, now I have to watch that again" - Caliber |
|
Posted by kodrik
on Tuesday September 28, 2010 @ 08:14pm >> [ reply ][ rating +0 ] You are right, the query will only load a whole thread because it uses the ancid which is the first post. But getting the whole thread in one query is still light on the database, you can then reorder by post date in the query or do more complex reordering in php, for nested thread, you can load all the messages in the query and just display the ones relevant with logic built in php. As for the indent you can just ignore i or have php control the display. In general, I prefer putting the load on php rather than the database (within reason) and avoid multi level recursive queries as much as possible as they can be very taxing as it branches out. I just realized that is actually what you did in your pseudo code below. message_rootid is ancid, your name is better, mine is shorter :) I would not wish to a dog or to a snake, to the most low and misfortunate creature of the earth-I would not wish to any of them what I have had to suffer for things that I am not guilty of [...]; but I am so convinced to be right that if you could execute me two times, and if I could be reborn two other times, I would live again to do what I have done already.~Bartolomeo Vanzetti |
|
Posted by voltaic
on Thursday September 23, 2010 @ 07:51am >> [ reply ][ rating +0 ] Let me pseudo-code an idea here and see if it makes sense. SQL query #1: select * from messages where messages_rootid=X; This single SQL query would pull all messages under the root (first post in a thread). Now you have them all in an SQL result set. Save result set into an array (you can do other pre-processing you might need here, etc) Add a new dimension to the array which I will call ["display sort order"] Create global temp variable displaysortorder=1; Set the root/first post ["display sort order"]=1; Now recurse over the array something like this: sort_sub_messages(var parent.id) { create a temp array of unread submessages with parent.id=my.parentid, sorted by post date create a temp array of read submessages with parent.id=my.parentid, sorted by post date iterate over the unread tmp array for each, set my.displayorder=displaysortorder++ recurse by calling sort_sub_msgs(my.msgid) iterate over the read tmp array for each, set my.displayorder=displaysortorder++ recurse by calling sort_sub_msgs(my.msgid) } Once done, print messages to the screen sorted by displaysortorder. I'm sure this will barf somewhere and need work. Plus it's "not elegant" since it's iterating over a temp global variable (displayorder) but that's my first thought top-o-the-head. "That dude has the world's biggest forehead... great, now I have to watch that again" - Caliber |
|
Posted by voltaic
on Thursday September 23, 2010 @ 07:57am >> [ reply ][ rating +0 ] Or you know, alternately you could do a single SQL query like I wrote above, and then just write a "pseudo-SQL" function in PHP that in a sense queries against the SQL result set. The code would essentially work as now except with only one SQL hit. Then with the flexibility of your PHP pseudo-SQL query you could implement paging, etc. In any case I don't think you're going to get a performance improvement above O(log n) or whatever it's running now. You'll just be moving the work from SQL to PHP, which is good but not in any sense easier. :) Later on I'll try and find time to read the link you posted about nested sets. Sounds like one of those things where they add a new array dimension with every subset and order them thus? I did that in the forum software I wrote for the vampire games back in the day. It worked. "That dude has the world's biggest forehead... great, now I have to watch that again" - Caliber |
|
|
|
Posted by Krux
on Wednesday September 22, 2010 @ 11:44am >> [ reply ][ rating +0 ] I don't even understand what you said! I suspect volt would be the only one on here who would. Mainly I need a way to figure out how to dynamically sort a list of nested messages but pull them in with a single SQL query. So one field I know I'll have to sort on will be a test condition, date-time >= last-read-date-time. returns a 1, if true, so that would be how we say group new messages and already read messages. So say the messages were posted in this order:
If you haven't read anything they would display in that order, however say you have already ready all the messages up to 5, and everything from 6 on is new. Then it would display like this
The idea is that you move the new messages closer to the parent message so it's easier to go back and reference if needed. Quoting limits the need for this, but you don't always quote, or perhaps you want to re-read the original message in it's entirety. Looking at some test posts however, I think it's really doing this currently:
Which isn't really what I want, and probably a bug in my code, or maybe I just didn't get around to finishing that feature. "Money isn't everything... It's also the goods and services that you can buy with the money." |
|
Posted by Krux
on Wednesday September 22, 2010 @ 08:49pm >> [ reply ][ rating +0 ] Apparently what I want is the nested sets model, though it does give up the ordering based on user, though given that it hasn't been working in forever, that isn't a big loss I suppose. http://dev.mysql.com/tech-resources/articles/hierarchical-data.html "Trippin' our brains off, killing kids, raping women...Viet-fucking-Nam! God I fucking miss it!" 'When were you in Vietnam?' "'93, come to think of it, maybe it wasn't even Vietnam. Maybe it was South Philly." |
|
Posted by Stealth
on Wednesday September 22, 2010 @ 12:42pm >> [ reply ][ rating +0 ] I get it, but i don't understand the downside of whats happening, besides the lack of paging. You say you like the way it displays new messages towards the top of a thread, but you don't like the way it works? Would you like to display the first 100 messages or just the newest 100? That later would be easier I imagine. The first would probably put new messages on later pages, which would suck. have you considered how slash does it? besides the rating system, something that might be useful? "God damn cocksucking hoopleheads!" |
|
Posted by Krux
on Wednesday September 22, 2010 @ 08:58pm >> [ reply ][ rating +0 ] I get it, but i don't understand the downside of whats happening, besides the lack of paging. In a thread that is hundreds of messages, it takes a hell of a lot of processing to run a SQL query to retrieve each message. You say you like the way it displays new messages towards the top of a thread, but you don't like the way it works? Would you like to display the first 100 messages or just the newest 100? That later would be easier I imagine. The first would probably put new messages on later pages, which would suck. Well because it does it but only by just displaying the messages newest first, instead of oldest new message first. "You just wasted a few moments of your precious life with yet another web video of some person/animal doing something that may or may not be funny. depending on your mood or how drunk/high you are." -- Stealth |