Hi I have /groups, /groups/{group_id}, /groups/{group_id}/objects and /groups/{group_id}/objects/{object_id}. Currently I have the server create a “hit” every time a user fetches an endpoint. So for example, GET /groups/{group_id} increments the hit count for the specified group, and GET /groups/{group_id}/objects/{object_id} increments the hit count for the specified object. I used these hits during search to rank groups and objects by popularity.
The problem is that I allow ?include=objects. So the client currently just fetches /groups?include=objects and uses that to build up the models in the app. So when users click on a group to see it, the server has no way of knowing.
Here are a few solutions:
- increment the hit count for every item in a collection when the collection is fetched <- not ideal because browsing the main feed increments hits
- force the client to fetch groups and objects by id when they are clicked (perhaps by not including attributes in collection responses) <- not ideal because this seems to break the jsonapi spec?
- increment the hit count for every item if ?include=objects is present <- not ideal, feels like a special case?
- rely on the client to do the right thing and call GET /groups/{group_id} when the user clicks a group <- not ideal, potential for inaccuracy
These all have their drawbacks and I’ve been spinning on this for a few days. I think the issue is that pre-jsonapi I might have only returned group IDs for collection responses, forcing the client to fetch items by id.
Is there something I’m just not seeing? Has anyone else come across this issue?
Thanks!