Hello,
yes, when retrieve_order=1, then order has to be combination of columns »priority« and
»received_time«, because there can be multiple records with the same priority, but with
different received_time. And we would like to publish the newest status.
My example:
mysql> select id,username,received_time,priority from presentity where username=3915
and event='presence' order by priority desc, received_time desc;
| id | username | received_time | priority |
+----+----------+---------------+----------+
| 34 | 3915 | 1464775887 | 60 |
| 33 | 3915 | 1464775876 | 60 |
| 32 | 3915 | 1464775869 | 40 |
| 30 | 3915 | 1464775844 | 40 |
| 26 | 3915 | 1464775811 | 40 |
| 35 | 3915 | 1464775894 | 20 |
+----+----------+---------------+----------+
All the best,
Ales
From: Daniel-Constantin Mierla [mailto:miconda@gmail.com]
Sent: Wednesday, June 01, 2016 11:47 AM
To: Aleš Šturm; 'Kamailio (SER) - Users Mailing List'
Subject: Re: [SR-Users] Wrong Publish status
On 01/06/16 10:42, Aleš Šturm wrote:
Hello,
yes, if the priority is the same, records should be ordered by received_time. Acting in
this way, when “presentity” table has more than one record of the same user with equal
priority, to watcher would be send Notify message with last received status.
SQL like:
select * from presentity where username=X and priority=Y order by received_time desc;
Well, the priority is not known in advance, query is like:
select ... from presentity by matching the user and event, ordering either by receive_time
when retrieve_order=0 or by priority if retrieve_order=1.
Here it looks like order by has to be a combination of the two columns.
Cheers,
Daniel
--
Daniel-Constantin Mierla
http://www.asipto.com -
http://www.kamailio.org
http://twitter.com/#!/miconda -
http://www.linkedin.com/in/miconda