bastislack / highline-freestyle

Webapp for Highline Freestyle
GNU General Public License v3.0
10 stars 9 forks source link

Updates to the tricklist are not applied if a trick is saved in the userTricks #194

Closed bastislack closed 1 year ago

bastislack commented 2 years ago

I changed the video link of the chrysalis but when it is ticked on the list it gets saved as a userTrick and thus is not updated.

weberax commented 2 years ago

I have an idea for this:

To simplify this process, we could also consider to simplify the whole push trick component (and the db), so that the user added tricks will be much simpler than the predefined ones. Maybe just name, lvl, and notes...

@bastislack what do you think?

rorystephenson commented 2 years ago

I think @weberax's solution makes sense.

Actually reading this issue made me realise it's probably time to add some testing so that we can write tests which check that we handle more complex things like this correctly. I've opened a PR for it #199 .

weberax commented 1 year ago

(just for the archive... no discussion needed)

I implemented this now in 2382e36:

Now only the explicit changes of the user are saved. Before we saved a copy of the original trick in the userTricks table, now this table only contains the explicit changed attributes. Also for every trick query (single or multiple) the query has to merge the userTricks table with the predefinedTricks one and by encountering duplicates, keeping the user changed value. This is done with the mergeLists function.

This is different to how we discussed the solution here beforehand, but should work, as long as the user never updated the fields, which we want to update as well, in this case the user won't see our update. But that might be also a good feature.

At some point we would want to probably track, and show the user, which data he modified, so he could also reset individual fields. But this we can do after maybe even considering an total refactor of the whole database.