eXaminator / kanka-foundry

FoundryVTT module to import information from kanka.io
MIT License
22 stars 8 forks source link

Locations import #82

Closed ScyllPoesis closed 2 years ago

ScyllPoesis commented 2 years ago

Would it be possible to import all direct child locations of an entity? Either as a part of the entry text, or in one of those neat tabs (could fall under Related in my eyes).

Thanks for the nice work!

eXaminator commented 2 years ago

Hey, I'm not 100% sure if I understand what you mean. So here is what I understand:

You want to import a location (and possibly other entities that can have "children"), and have all locations that are children (and probably their children etc.) to import automatically with that initial location, right? So the use case would probably be something like importing a city with all its shops etc.?

I think that would be possible, but realistically only for the initial import, not for later updates (but for that there is already the button to update everything that is outdated). The biggest problem would probably be the time it might take, because this could lead to a lot of requests to Kanka, which are limited per minute. But as we already have buttons that allow importing of multiple entities at once, that shouldn't be a big problem.

Pleas let me know if I understood you correctly.

I will think about it, but I do see some use for this. So there is a good chance I'll try and implement something like this once I start work on the next update (which I'm planning on doing probably within the next week or two).

ScyllPoesis commented 2 years ago

Close, but I think I mean something even simpler! Let me give an example:

I have a City District location, belonging to parent location City. It has description blah and a few attributes danger: safe, climate: temperate. It also has some direct children locations like Merchant, Pub, Church.

Currently the import generates a tidy journal page that has a stat block list of entries for the type, attributes, parent location, and then the block for the entries. Explicit relations go in a nice tab, but if I wanted to have a list of sub locations currently I have to use the entry text with links to the other entities. So right now if I opened up the City District journal I'd have to explicitly write links to Merchant or Church in the text entry to have the links on-hand, or do some jank stuff with manual relations.

My proposal is simply to have it so that if City District has some sub locations, either have a tab like Relations (or just put them in the Relations tab like Kanka does in their visualizer), and list out the links to Merchant, Church, and Pub automatically.

I hope that makes it all clearer, but I have no idea about the data structure that gets returned back so I understand there might be API quota issues if the children locations aren't part of your response package.

eXaminator commented 2 years ago

Hey, thanks for the answer.

Yes, that makes sense, sadly it's not that simple.

The biggest problem here is, that Kanka doesn't give me a list of children, but only what its parent is. That means, I need to load all entities of a type, to find the children of any given entity. That being said, Kanka has recently added new filter options to the API, one of which is to filter by parent for certain types.

I will reevaluate this feature the next time I start working on this module again and see if I can find a feasible way to implement it, because I do think it has merit.

ScyllPoesis commented 2 years ago

Oof, yeah, I had a 50/50 hunch that was the case. I definitely don't blame you there.

For now it's really not a huge deal to put a small block of text linking to the sublocations, so agree with putting it on the backburner. Thanks for the commentary, hopefully the API develops to allow this sort of querying in a smarter way. Cheers!

eXaminator commented 2 years ago

Oh, I started the implementation for this yesterday. I already have a workaround for showing the "Ancestors" of an entry, which I can also use to show a tab with all the children. So that should be in the next release which I'm probably releasing in the next few days or so :)

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 2.6.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

ScyllPoesis commented 2 years ago

Hurrah! All praise the mighty lookup tables!