fmasa / wfrp-master

Unofficial Android companion app for 4th edition of Warhammer Fantasy Roleplay
GNU General Public License v3.0
11 stars 3 forks source link

Move Character items to Character document #285

Open fmasa opened 4 months ago

fmasa commented 4 months ago

Currently, each Character item (these are Skills, Talents, Spells, Trappings, Blessings, Miracles, and Traits) is stored as a separate document in Firestore.

This brings several problems because loading full Character means dozens of reads:

The idea is to validate how much data Character items usually contain because Firestore has a limit for document size (1 MiB). Ideally, the Character document would contain descriptions of items as well, but if this would stretch the limit too much, we can extract the description to separate documents, so we can show the Character details from a single document read and only fetch extra document when viewing e.g. Skill detail. We could also skip this for Compendium items altogether - currently, 10 Characters with Melee (Basic) skill mean that the description is stored (10+1)× (once in Compendium and one in each Character item).

This has some disadvantages:

fmasa commented 4 months ago

I will start with splitting domain character items and state needed in Character sheet tabs.

After that I think the sensible approach might be this - character items are still stored in subcolllections - this is a source of truth. Apart from that, some data are synced to character data (or to one subdocument). This should be everything needed to render character screen. I think it makes sense to store everything except for long texts there.