Join, Be Done
I’ll admit to cowering in fear of the join form for Nova. We’re doing almost completely dynamic character data, which means the join form has to be just as dynamic. In theory, it’s amazing just because of the flexibility it’ll give game masters moving forward. In practice, it’s a serious pain in the ass because of how it forces you to build code. You can’t assume anything. An RPG may not want to collect gender as a field. Everything has to be highly dynamic. It isn’t easy, but the benefits outweight the pain (at least that’s what I’ve been telling myself).
Yesterday, I managed to ge the join form spitting out the join form. Lovely. That’s half the battle. (Well okay, a third of the battle.) The rest of the struggle is saving all that data to be used by the system in later areas. Well, it isn’t an issue anymore. Today I managed to get all that data from the dynamic join form into the dynamic character tables. It’s a huge step forward and lays the groundwork for some awesome stuff with specs, tour items, and docking requests.
There still some stuff that needs to be ironed out with the join form, but I’m about 90% of the way to having one of the major hurdles of Nova out of the way!
Making It Better
I can’t even remember when the next and previous links showed up in SMS, but it was a while ago to be sure. When I build those links, I knew far less about PHP and MySQL than I do now. (It’s safe to say that SMS has been the ultimate learning experience.) When I did it, I wasn’t thinking about efficiency, I was just looking to get it done. As the years have gone by, I’ve definitely wanted to go back and fix it, but it’s the age old adage: if it ain’t broke, don’t fix it. Well, when the feature rolled around for Nova, it was my opportunity to fix it. I didn’t bother looking at how it was done in SMS because I didn’t want to get myself moving in one direction. Needless to say, Nova does the whole thing a lot better.
But, last night, it got me thinking about the solution I came up with for Nova versus what SMS is doing. I started to wonder exactly how inefficient SMS was in that regard, so I used my own sim as a testbed. I copied and pasted the query it was running and ran it in phpMyAdmin. The results? Well, before I tell you the results, let me explain how SMS builds those items.
First, SMS queries the database table (be it posts, logs, or news items) and pulls back every record that is activated. Every record. It dumps those items into an array, then searches the array to find the key of the item you’re viewing. Since array keys (in this instance) are sequentially, I just had to increment or subtract 1 from the current key to give me the one we’d be moing to. It worked when I did it, so I didn’t bother messing around with it. But what happens when there are a lot of rows? That’s where the results come in to play.
I ran the query for missions posts on my own sim. The results? SMS was pulling back 3,060 rows, taking the query a whopping 0.0923 seconds to run. Now to the innocent bystander, that seems really fast, but for anyone who’s used MySQL before, that’s actually a pretty long time to execute a query, say nothing of the fact that the database is returning over 3,000 rows just to get 2. Gross inefficiency right there. So what was the solution? Utterly simple is what it was.
SELECT postid FROM sms_posts WHERE postStatus = ‘activated’ AND postid > $current_id ORDER BY postPosted ASC LIMIT 1
That’s right, take the current ID and find all IDs that are greater than it, then limit it to 1, giving us only the next item. The same idea happens for getting the previous ID as well. Yes, it’s now 2 queries instead of 1, but those 2 queries return 2 rows and run in about 0.0026 seconds. Folks, that’s almost 36 times faster. Now, will you notice a speed bump or anything? Probably not, but you can definitely rest assured that one of SMS’s gross inefficiencies will soon be a thing of the past.
A Month of Checkins: Nova’s Progress in November
There isn’t enough weekly work being done to warrant going to weekly updates, but the following is an update on the kinds of things that were checked in to the Nova trunk over the course of November. This report covers revs 86 through 155.
- Template library updated to version 1.4.1. This update allows us to put the library into the framework core and extend it like other core libraries, meaning we can non-destructively add methods to the library and extend existing ones.
- Started working on sub-departments and setting parent departments in the database.
- Removed the Layout library from autoloading to save on resources.
- Fixed a variety of display issues.
- Updated a lot of documentation.
- Updated the location and language helpers.
- Moved the js directory from the root to the assets directory since multiple installations off the same core might want to use additional js resources.
- Moved to a simpler modal script than the one we were using.
- Finalized some pages.
- Added the player bio page.
- Changed templates over to use a strict DTD.
- Adding some asset directories like images (missions, awards, characters, etc.).
- Updated the rank short names.
- Renamed the js view files to avoid confusion.
- Making the view files more consistent and giving skin developers the most possible control over the view files we can.
- Updates to the models.
- Starting to work on MOD installation pieces.
- Making sure that the view awards, view posts, and view logs pages can see both a single character as well as all the characters a player has assigned to them.
- Adding application tracking database.
- Adding a Firefly genre to Nova.
So that’s a quick rundown on what we’ve been working on during the month of November. It may not seem like a lot, but we’re our damndest to get through M2 as quick as possible so we can start working on the meat and potatoes of the system. Over the coming months, we’ll have lots more updates. In addition, the follow pages have been finalized:
- RSS Feed for Mission Posts
- RSS Feed for Personal Logs
- RSS Feed for News Items
- Search
- Search Results
- Main index
- All News
- Site Credits
- Chain of Command
- Player Bio
- View Personnel Awards
- View Personnel Posts
- View Personnel Personal Logs
- Sim index
- Missions page (all missions and individual missions)
- List all posts
- List all personal logs
- Crew awards
The following is a list of pages that still have to be completed during M2:
- View news item (started)
- Contact page (started)
- Join page
- Character bio (started)
- Manifest (started)
- View mission post (started)
- View personal log (started)
- Sim stats (started)
- Tour
- Deck listing
- Specs
- Department listing (started)
- Docking requests (may be delayed until later in development)
- Docked ships (may be delayed until later in development)
Out of the above list, there are a handful of pages that are close to being finished. The contact page is just waiting on some QA work on the email, character bios are nearly finished, the manifest is just waiting on a decision point regarding com badge images as well as displaying sub-departments, view mission posts are almost done, view personal logs are almost done, and the department listing is just waiting on some style updates. All in all, we’re in a pretty good place. I’m expecting the list of pages to be finished to be much smaller come the first of the new year.
