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
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).
I’ve enabled Danbooru repository sync to Bitbucket again as I’m planning to work on it again – mainly upgrading to Rails 3 and reducing insanity required for installation. And perhaps import the danbooru-imouto changes back.
This morning I randomly decided to try installing danbooru on Windows (7-x64). And indeed it works. Mostly.
Using mongrel and nginx since unicorn is not available on Windows.
Few things to note:
* system_timer is missing since I can’t seem to install it. Probably need to try ruby19 or ruby18-1.8.6-p27 (currently using ruby18-1.8.6-p383)
* manual initial database initialization since the script I made is specifically for *nix systems
* compiling danbooru_image_resizer is… *fun*
* for whatever reason I can’t install mongrel_service
* apparently there’s something missing. Or broken. Or both – there’s message “The system cannot find the path specified.” every time I start mongrel and do migrate
…anyone interested trying this on production server? 😛
_Last update 2011-07-18 21:01: formatting, also added rewrite rule for nginx to cope with uploaded media path change_