Open Rupeshiya opened 4 years ago
@vaibhavdaren @devesh-verma Please add your view. Also is there any other optimal method we can use?
@kmehant Here is the issue to start with and the given below approach we are going to use.
@Rupeshiya @vaibhavdaren
I am thinking of this data model for storing user activity on redis cache
A redis hash for routes
<email>
<Route1> <Unique Hash 1>
<Route2> <Unique Hash 2>
<Route3> <Unique Hash 3>
....
A redis list for time stamps
<Unique Hash 1> <Timestamp 1> <Timestamps> .....
<Unique Hash 2> <Timestamp 1> <Timestamps> .....
I have adopted this model for making use of atomic operations of redis.
When pushing to mongodb, we we can simply join the routes with their timestamp lists by matching the hashes and push it to User collection.
Great @kmehant, Also when you push the data to db then store that in a simple array of objects. In addition to that, it would be great if you send pseudo code or WIP PR.
@Rupeshiya @vaibhavdaren @devesh-verma I have written a middleware #150 and description here https://github.com/codeuino/social-platform-donut-backend/pull/150#issue-448995557 Please review
Is your feature request related to a problem? Please describe. As of now, there is no such API that can showcase the activities of a particular user on the platform. So the feature request is to implement the API for tracking the activities of the user which only admins can check.
Describe the solution you'd like Implement REST API for tracking user activities. We can implement this in either of the two ways listed below (from my point of view)
We can make a self-object for the user and keep on adding the activity of the user on that object and save that to DB. Something like we did for the notifications system.
We can also implement this without using any extra space as we are already saving every info of a user like, which user created what, liked which post, commented on which posts. So here in this approach, the only thing we have to do is that just iterate through all the user-related documents and deep populate to fetch those data and sort according to the date and send that in response.
Note: This is not realtime implementation