Tell a user whether they have already viewed an item in a list. How?
- by user2738308
It is pretty common for a web application to display a list of items and for each item in the list to indicate to the current user whether they have already viewed the associated item.
An approach that I have taken in the past is to store HasViewed objects that contain the Id of a viewed item and the Id of the User who has viewed that item.
When it comes time to display a list of items this requires querying for the items, and separately querying for the HasViewed objects, and then combining the results into a set of objects constructed solely for the purpose of displaying them in the view.
Each e.g li then uses the e.g. has_viewed property of the objects constructed above.
I would like to know whether others take a different approach and can recommend alternative ways to achieve this functionality.