G
G
Graube2013-12-31 19:41:18
PHP
Graube, 2013-12-31 19:41:18

Unread messages and comments

Hello everyone,

First of all, I congratulate everyone on the Upcoming/Upcoming!

The question is as follows: When displaying messages, it is required to mark new (messages) with special icons, as is done on lj, habr, etc.

From more or less small bicycles, it comes to mind to bind to the viewing time:

There is a condition:

если ( ДатаПоследнегоПосещения < ДатаПоследнегоКомментария ) 
то { пометить маркой все комментарии с датой больше ДатаПоследнегоПосещения и обновить ДатаПоследнегоПосещения }

and a database with a table (Post ID, User ID and Last Visit Date).

In this case, there will be a "conditionally large" number of records in the database. The quantity itself does not frighten, this method frightens, in connection with this I am interested in whether there is a less cumbersome method.

Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
JhaoDa, 2013-12-31
@Graube

What else can you think of? Select all messages related to the desired topic and with a time older than the last time the user was active in this topic (or on the site in general). With a normal data model, with indexes, everything will work.
And you know, the “number of records in the database” depends on the tasks - for someone, 100,000 is already a lot, and for another, even 10 million is normal. Few details...

T
tenshi, 2013-12-31
@tenshi

can be optimized as follows: by default, we consider all posts to be fully read, but when a post is created, set the reading time for all users = current. and every day to clean out all such records that are older than, say, a year. then, with 500 users and 150 posts per year, we get no more than 75,000 records at a time. when visiting the record, of course we update / add, but these are trifles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question