We will require a stream model to build the status stream from the database. The functionalities required are:
- Looking up an activity in the user's network
- Formatting the time of these updates to make them more relevant; for example, 5 minutes ago
- Retuning the stream
- Knowing if the stream is empty
Code for the model is saved in the
Let's walk through the logic of how building a stream of updates would work:
- We will need to get the IDs of users the current user is connected to.
- As the IDs will be imploded and used as part of an IN condition, the list of IDs cannot be empty. So in case it is, we should add an ID of zero to the list.
- We then need to query the database, pulling in the 20 most recent ...