Multiverse Feedback: Cardlist | Visual spoiler | Export | Booster | Comments | Search | Recent activity |
Mechanics | Upcoming releases | Skeleton |
History: [-] Add your comments: |
Multiverse Feedback: Cardlist | Visual spoiler | Export | Booster | Comments | Search | Recent activity |
Mechanics | Upcoming releases | Skeleton |
History: [-] Add your comments: |
The option on the front page to "See a Random Selection of all the cards on multiverse" tends to result in getting an Application Error screen, no matter what web browser I use. It works sometimes... but lately it only seems to do its job one out of every four days I try it.
Which kind of stinks. Because I was hoping to add some random cards from Multiverse into my According to Gatherer Cube. It isn't a real problem, since I can just take random cards from 'Cards with no home'... which in retrospect is probably more appropriate anyway. But multiverse.net/random still needs help.
Ah, yes. That's going to be particularly resource intensive with the tweaks I made to mechanics, and Heroku is still killing any request that takes longer than 30 seconds.
I have some performance enhancements in my sandbox which I should really deploy in the next few days, which I hope should remove a lot of the extra delay and perhaps even improve performance relative to before the mechanic tweaks.
Would it be worth making "show a random card from multiverse" as a workaround (maybe add a secret "/random?n=1" parameter or something?).
As it happens, there is :) http://www.magicmultiverse.net/random?count=1
Oh cool. OK, I'm wrong twice over, because I didn't realise that existed, and I assumed that, if it did, the overhead wouldn't make it timeout :)
In retrospect, maybe jmg's workaround is "go to random.org and get a random number between 36 and 81862" and "go to http://www.magicmultiverse.net/cards/[that number]"
PS: jmg, I'm enjoying reading that series.
I really don't know why the /random function is so slow. It shouldn't actually be pulling every card out of the database. It will be pulling up the cardset permissions and the mechanic text for every cardset represented in the randomly selected cards, but that shouldn't affect the case where there's just one or two cards, especially given that popup previews of an arbitrary card are so quick.
Hm. Yeah, I'm a bit confused. You thought it was slow because of what you did to the mechanics? But it looks like it's choosing even one random card that's slow, not so much displaying it.
Is the github code up to date? My l33t google-fu says, it is basically just doing "Cards.nonsecondary" and then calling "sample" on that. Is there something about that that means the entire array needs to get loaded when it looks like it shouldn't? Or is something else the problem.
I believe "Cards.nonsecondary" is what's called a "scope" in Rails terms. It's not actually accessed anything from the database yet. ".sample" operates on a ...oh. Oh. The sample method operates on an array, not on a scope... so it is pulling in every card from the database, because it's converting the scope into an array of every card!
Right, that's a moderately simple fix then.
fixed!
Oh cool, nicely done! I'm glad I was going in the right direction.
I've mixed feelings about the "here's a thing that's like a lazily-loaded array". I like the idea a lot, and when it works, it lets you do a lot of stuff very clearly and efficiently. But there always seems to be a point where it's secretly converted to an array when you don't quite realise.
@Jack: Oh, hey, thanks!
@Jack & Alex: Excellent work! I wasn't expecting the problem to be hashed out when I woke up. :)
Hm... I guess I should bookmark the single random card address. I'm not sure if it has a use to other users, since a sample booster and/or 15 random cards seems to be a better way to get a glimpse into what's in Multiverse... and that might be the best way for people to experience random cards from this set. But with my article series, it's best that I get a single random card. Otherwise, I could be distracted by the other cards that populate, tempting me to choose a different card, and tainting the results.
One card would also make make sense for things like mashups, where you also want to choose one card and not get distracted. But OTOH, I always just made up my mind in advance to use the first card listed and that worked fine.
The reason I implemented it at all was for mashups, actually :)
There's a (not very) secret page http://www.magicmultiverse.net/mashup which Vitenka asked for, which is a frameset containing a random Gatherer card (when Gatherer isn't down), 2 random Multiverse cards (as often the first one is blank or otherwise unsuitable), and a Create new card window in the community mashup set :o) Anyone can feel welcome to use it... in fact, perhaps we should link it from the mashup set's front page.
Woah. That is one funky page.
I should get back in the habit, really.