Answer the question
In order to leave comments, you need to log in
How to create a subscription feed?
There is a social network application where people publish videos and can subscribe to each other. So the question is how do I need to create a subscription feed for a user (who has 200 subscriptions, let's say), how do I check for new publications from those people I subscribe to? How it is necessary to do it that not to put a DB? An example of what needs to be implemented is the feed of subscriptions from Instagram.
Answer the question
In order to leave comments, you need to log in
1. table-list of users to whom you subscribed (who you want to read)
2. feed table: posts you read - post ID, user ID and flag (what is read)
3. "Unread" < 200 => request to publications of users sorted by TIMESTAMP and do not forget to specify LIMIT in the SQL query, at the end of the query...
4. We enter the read records into the feed table with the flag: "not read"
5. Display the feed of posts from step 2.
What prevents instead of checking "if there is anything new" to send a notification to subscribers at the time of publication?
websocket will help you . The client itself does not request anything (unless the user presses the buttons). The update occurs when a publication occurs on the server: the client publishes the news, the server looks at who is subscribed to this person, looks for active connections with subscribers, and if it finds it, it sends them the command "there is a news update", after which the button "there is new news" lights up for subscribers "or something like that.
The simplest solution is to add a field to the user model with the time of the last receipt of subscriptions
. When the user arrived, we check if there are topics older than his time of receipt of subscriptions. If there is, we give it topics and update the timestamp
A correctly - you need to form an m2m connection between users and posts and set a label for each individual line ( user_id, post_id )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question