Latest push:
- Implement ability for staff to move topics with an optional redirect.[1]
- Removed all database queries from the homepage so that it loads almost instantly (always a cache hit).[2]
Technical notes for the badass hackers:
[1]: The "redirect" (on by default) is a "Topic moved" papertrail message that shows up in place of the topic on the origin forum so that moved topics don't just vanish. What seems like an easy feature ended up taking a while because I basically had to change from simply sorting topics by
latest_post_id
to sorting topics by moved_at
(timestamp) and latest_post_at
(timestamp). I struggled to do that sort performantly til my friend pointed out that I can create an index on the expression (topic.moved_at OR topic.latest_post_at)
. Blew my mind.
[2]: I've been slowly moving database queries to a simple cache object I created that refreshes each cache item at some arbitrary interval in the background (source). That way cache reads are always instant. By caching the homepage's list of categories, forums, and latest posters (updated every 10 seconds), I reduced the homepage load time from 20-50ms to <1ms on localhost.
So far I've spent the rest of my time working on the "Hide" system. I'm essentially trying to replace all destructive deletion with a system of is_hidden = true
flags. For one, that will make all "deletes" reversible. There really isn't a good reason for a forum in 2015 to delete data, but I also just want to set the stage for user-level deletion. It's pretty hard though.
Next weekend I will pick more enjoyable features to work on for sanity.