Closed AceMgy closed 8 years ago
Would it be too much, if the statics would be replaced with mapping table? This would in theory support more statics than there currently are. Also it would remove any special cases handling "is there 3rd statics" as the statics would be handled as list in ever place.
Is this how to do that?
https://docs.djangoproject.com/en/1.4/topics/db/models/#intermediary-manytomany
New to django so I just coded what I knew. I agree that would be superior. Would even allow room for a statistical tool that auto-discovers statics later.
Yeah. It's meny-to-meny relations ship, so that seems to be the correct documentation. I presume defining the models is easy, but I have no idea how to do django migration out of this. Migration needs to move corrent data to new table and then remove colums from current table.
Migrations worked for me on my test server but it simply wiped all the data on wormhole statics and started anew with a many-to-many field. That means that I'd have to change all the */fixtures/*.json
to deal with this or all that data will be lost on upgrading.
Time to get good with sed.
@AceMgy Be careful dude those are docs for Django 1.4, not 1.8!
AFAIK migrations can be created automatically after you've updated the models. More info: https://docs.djangoproject.com/en/1.8/topics/migrations/#workflow
Don't merge this pull request yet. Just found a nasty bug in:
Basically it's not playing nice with the initial setup of the database. Simply adding the static3 field doesn't work. Trying to find the source of the exception right now.
Done. As far as moving statics to a many-to-many field I'm playing with that on my own branch. Triple statics work in this pull request just fine as far as my testing can tell.
No shattered system statics added yet, stay tuned.
All right, well that was educational.
Turns out ManyToMany fields in django are pretty funny. If you let it create its own intermediary table, you cannot have multiple non-unique values in it. There is one system where this is a problem: Thera. And I'm too much of a perfectionist to let this slide.
So, you can create your own intermediary table using models.ManyToManyField(Blah, through='cust_intermediary_table')
. However, doing so you loose the functionality of .add() because it cannot auto-populate the intermediary fields because :django:.
So, I had to make quite a custom data migration that got around this limitation by directly creating the intermediary table "SystemStatic." That was the hard part. After that I just had to update the .json with a data dump and get the templates to work.
That's enough work for today. I'll add the actual shattered system statics soon.
I'll check if I can test and peer review this. For now, it looks good. Nice work.
Next problem is to find some trusted source for the statics. The spreadsheet has some, but there is lot missing.
I'm just going to add the statics @ http://wiki.eveuniversity.org/Project_Reassembly/List_of_Shattered_Systems cross-check them with that other spreadsheet, and leave out any conflicts.
I think I'll just leave the rest out. It's becoming pretty obvious that nobody knows all of them.
Oh, and I talked to a Thera eve-scout guy about the Thera statics for testing: http://i.imgur.com/XmlhsOF.png
I went ahead and made add_static() and del_static() functions to make this job easier. I tried to use this to practice using validation and exceptions and it seems to work well. I invite criticism on this, though, as I'm learning.
For the shattered statics I compared the data between the uni's project reassembly and this spreadsheet somebody linked. If they disagreed I left it out. Turns out I trust the second spreadsheet a lot more because the uni's one often breaks the rule that each shattered has an additional K-space static like many dev-posts mention.
Except for Thera and J005923. Thera I talked to a guy in eve-scout that scans it out every day, J005923 I'm trusting @raphendyr here. ;)
And with that, I consider this feature complete on my end. (Except for all the other shattered statics I'm expected to maintain from now on, lol)
Simply added functionality for systems with three statics. (i.e. shattered C2s and C4s as discussed @ #222)
Still need to actually add the shattered-system statics, but that looks like it's going to be quite a job so I'm submitting the PR now in case I don't get to it.