H
H
hbrmdc2016-07-14 21:05:25
JavaScript
hbrmdc, 2016-07-14 21:05:25

How to organize the marking of "viewed" materials?

Using YouTube as an example:
I watched a video, and now I want this video to always be marked as "watched". That is, my history must be saved somewhere. But what if I have been using YouTube for a long time and managed to watch 10 thousand videos? How does YouTube mark videos that have been watched?
I have node.js server, react.js+flux front and PG subd.
Here's what came to mind:
The story is overloaded with unnecessary information - when I looked at the name of the video, etc. This infa is needed for other cases. I will do a search and pull from PG only the uuid of all the videos watched. I will translate it into an array form and send it to the client side. The client will store all this in localStorage and mark it with a date so that from now on the server will give only the missing part of the history. When rendering those pages that need to be marked as "watched videos", I will get the locally stored history and use the simplest way to check:

if(arrayWithAllWatchedVideosUUIDs.indexOf(currentVideoUUID) !== -1) {
   пометить как "просмотренно"
}

What if I need to render 100 videos at once, and they all need a "viewed" check? Will it cause difficulties?
Is there a better way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2016-07-14
@leahch

I would not use sql for these purposes at all. This is data that, basically: is temporary, limited (100/1000/10000 records, etc.), does not affect the main functionality, can be counters, there can be a lot of them, it would be nice to extract them very quickly, using them no need to do a lot of processing, they have a "lifetime" ...
Therefore, I suggest looking towards redis.io which is created for this!

S
sim3x, 2016-07-15
@sim3x

Serial:
- id
- name
- ....
Series
- id
- series = ForeignKey(Series)
User
- id
- name
- ....
- series = ManyToMany(Series)
https://en.wikipedia.org/wiki/ Many-to-many_(data_model)
If you don't need aggregation by users, view counters, or if you need consistency, then you replace ManyToMany with a list of series IDs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question