Be careful when using read_multi with dalli: it may return nil-valued key instead of the correct key.
The issue is tracked here and thanks to this I dropped the read_multi usage in moebooru and used the much simpler (and most likely slower) single fetch (per entry) instead. There’s alternative way to use it – do a read_multi and refetch whatever missing/nil-keyed but apparently I’m too lazy to do it.
Finally reached the goal: Rails 3.2.6. The isn’t much change between 3.1 and 3.2 which is why I skipped 3.1. As there isn’t much front-end change, it means there isn’t any user-visible changes. Or at least there shouldn’t be.
Move to jQuery
Use paper_trail for versioning (or something else)
Add SVG support (and maybe drop SWF support)
Actual news ticker
3.2.0 has been branched and currently running on some servers. The next version, 3.2.1 is on default branch and being tested on moe.myconan.net. As (finally) there are database changes, it will not be tested directly on live servers until it is stable enough.
Changes include better support for JRuby, use mini_magick instead of custom plug-in, less monkey-patches (but more bugs), and various clean-ups.
After working on it for several weeks, finally it got to the point where it’s relatively usable. No more Bundler-on-Rails2 evilry and the fact that 3.0 branch is still supported.
The best part is the one above. Yes, Moebooru now runs on Rubinius/Puma. The only foreseeable problem is it uses Process.pid on file uploads which, when several people uploading (or working with) files at same time, the temporary filename will collide.
Though due to me aiming more for workable implementation instead of correct implementation, there are quite a lot legacy stuff still in there:
repeated_auto_complete doesn’t work in Rails 3 without vendoring or updating the gem itself (and I did both since Bundler’s git functionality seems broken in Rubinius).
prototype_legacy_helper must be used since I haven’t had time to upgrade the *_remote functions (and still thinking how to do it).
verification gem since I haven’t upgraded the route and its functionality, which previously built-in in Rails 2.3 has now removed.
Unsightly lib/core_ext. Just look at evilry I have added to make it behave like 2.3-stable.
On the brighter side, now I can start cleaning up the code. Or upgrade all the way to Rails 3.2 ( ¬‿¬)
While digging more into the code called “Moebooru” which was forked from “Danbooru”, I noticed this:
connection.execute("update table_data set row_count = row_count + 1 where name = 'users'")
connection.execute("update table_data set row_count = row_count - 1 where name = 'users'")
Counting takes ages, right. Except it is not. I’ve done this, yes, but on a table with 10+ millions of data (this one has ~400k in mainline danbooru), with multiple data inserted (this one got, uh, one every other week?) and queried every second (see below), and with the required count method not a simple select count(1) on some_table (which is what the example above used for).
The best part? It’s only used once, when user registers:
if User.fast_count == 0
self.level = CONFIG["user_levels"]["Admin"]
self.level = CONFIG["user_levels"]["Unactivated"]
self.level = CONFIG["starting_level"]
self.last_logged_in_at = Time.now
Since I forgot to branch the original source, the branching looked awesomely crappy. Therefore I decided to rebase entire thing to ease up keeping track with Moebooru “mainline”. All my commits are now in branch “default”. If you didn’t do any change, backout up to revision 9174b6b5b02d and then pull again. And then, don’t ever touch moe branch again anymore.
And more!: I hope you didn’t expect me to do more while there are incomplete items above.
Sure looks good. Need more testing though. There’s also one part which I totally had no idea why should be changed when upgrading to 1.9. Just grep for FIXME to see which it is and hopefully fix it up for me (or explain what it does).
As usual, having completed the work for today, live demo is up and open for everyone to break (…if there’s anyone, that is).