So, say I have this blogpost schema and I want that, when blogposts are listed, it shows the user (that is logged in) the ones they starter reading or finished reading.
The way I solved it was by creating an association with a Complete schema that belongs_to a BlogPost, that in turn has_many of these Complete. This complete schema just holds who the user is, the completion status (false for started reading, true for finished it, null being not even started) and an access counter.
So it does work well; I pass a query when preloading this Complete association filtering by the user and it returns all the data I need, but that means that this complete information always comes as a list of structs (which would be either empty or having one element) and I feel like it would be cleaner to have just the boolean that defines the status of Complete (which is all I need to show the user, anyways).
My first thought then was to map the result and create a new field for each BlogPost and assign the status value from Complete, but I can’t help thinking there might be an easier/more efficient way to achieve it?
Perhaps there’s a better way to this entirely?