Board Thread:Support Requests - Getting Technical/@comment-653063-20150322192914

How many #switch is too many #switch? If I have to ask, the answer is "you have too many," right?

Good afternoon. I'm so sorry to be bothering you again, but I appear to be coding down a path that may be unwise, in terms of server load. I've read here and there ( http://community.wikia.com/wiki/Admin_Forum:Switch_parser_functions for example) that too many #switches on a page can cause load problems; and if there's something simple enough that I can do to reduce the load, but still accomplish the goal of "not have multiple templates that do effectively the same thing but only 1% different", then I'm interested in learning how to do that.

Structure of what's going on/my end goal: I'm making a table to display data about weapons. There are 4 games out now, the 5th is releasing in Japan later this week, and there's another spinoff game that may have its own separate weapon data (I haven't gotten that far to find out yet). So functionally, 5-and-maybe-6 pages that are(/will be) titled "List of Disgaea # Weapons." Each page contains a chart that lists all 40 (plus some extras, in some games) of each of the 9 (plus a 10th for one (two?) game) weapon types, 'sword,' 'spear', etc. In D1&2, 'crit' was not a stat on characters and weapons, but in 3&4, it is (plus 4 has 'move' and 'range' columns, ughh so much more coding i need to do, haha : x),. So I sometimes need to hide an entire column (or two, or three)...

So: In the template http://disgaea.wikia.com/wiki/Template%3ADXWeapStats, I wrote a switch, based on a parameter called 'disver' (disgaea version), so that, on a per-row basis, for D1&2, the cell that shows 'crit' doesn't show, but for 3&4, it does. At first my only concern was 'wow this is annoying to code'. Then I did the math, that each table does a #switch about 47 times. Times, lets just aim high and say 10 tables per page. That's 470 switches on one page. Plus there's another template I want to write and stick on the same page that will handle weapon skills, which will also have some switches, maybe 3 per table, but times 9 or 10 weapon types. There will be 5-and-maybe-6 pages that do this. This sounds... maybe bad.

I've got all the stats (not skills) tables into the template on this page - http://disgaea.wikia.com/wiki/List_of_Disgaea_3_Weapons - if you'd like to see it in all it's gloriously excessive action. (Thank heavens for the collapse function, and it's still a pain to scroll through, haha.)

My assumption is, "~500 #switches on a single page is bad." Question one: is it really that bad? Or is it "a lot, but not awful, stop worrying"?

(I don't know how much this factors into things, but - http://disgaea.wikia.com/wiki/Special:LongPages - 4 of the top 5 longest pages deal with weapon info. And compared to, say, http://finalfantasy.wikia.com/wiki/Special:LongPages - Disgaea's longest page has the byte-size of the #30 page on FFWiki. So maybe I am worrying over not much. Granted, by the time all the data gets to where it should go, any given 'List of Disgaea # Weapons' might be... 150k? I mean, that seems like a lot, but maybe it's really not...?)

Question two: Even if it's not hideous and to be avoided, is there a better/less-(server?)-'intense' way to get this done, that will still allow me to use a single template for all games? I'm all for efficiency, but I also recognize that I'm sure I don't know a tenth of what I could/should about wikicode. (ok maybe I know 10%, by now. Probably not 50% tho. I just never assume I'm done learning. There's always something else out there I could know.) I thought about doing an #if, as in, 'if the cell has data, show the cell," but even in D3&4, the cell might not have data, but I'd still want to show it. I guess I could do it as "if the cell at the head of this row has data, show the crit cell." Is #if less 'heavy' than #switch? Since I'd... no wait, I still have to run it as a function of disver. Nevermind.

I mean, am I thinking about this right? That every row, I have to re-check disver in order to hide/show the cell?

my "|#default=" option (haha) is to not have 'DXWeapStats' that contains 47 switches, but make separate templates for each game, "D1WeapStats", d2, d3 etc, that would be correctly formatted for each game. Then I can have, like... ... (*still thinking*)... well, yeah, no switches. I think. I'm pretty sure, no switches if I do game-specific WeapStats. It's just... the whole point of all the work I've been doing for six weeks is to reduce the amount of duplicated crap everywhere. Should a change ever want to be made in the future, then a person would have to change 5+ templates. But on the first hand in the first place, too much server load is bad all the time, and 'changing multiple templates ohs nos wahh wahh' is... way less bad, at some theoretical point in the future and wouldn't take that long anyway (compared to how many times a server-heavy page would be loaded in all the months in the meantime). If my goal is 'templates make things smaller and faster,' then in this case, 'ONE template to do all the jobs' might actually not be the answer...

So, yeah. "Am I blowing it up?" and, "Is there a better way to not blow it up (but still only have one template for all games)?"

(I thought about using template substitution, except that means all the actual data would be on a particular page, say "D3WeapStats_Axe" which would call "DXWeapStats," and then on 'List of D3 Weaps' I would ((subst:D3WeapStats_Axe))..... except that means I'm creating one page per weap type (10) times 6 games, is 60 pages, and that is a ridiculous solution. Plus then I have to document how to tell future editors how to delete the right bits and re-subst in later, in case of changes... so yeah, bad idea.)

SannaSK (talk) 19:29, March 22, 2015 (UTC) 