diff options
author | zotlabs <mike@macgirvin.com> | 2017-01-29 14:45:25 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-01-29 14:45:25 -0800 |
commit | d5d67708ac912fa863a062e3469eb4ac17e84cdf (patch) | |
tree | 86726237b4c0f11ab62dd04cc25cb1a223ac37a3 /Zotlabs | |
parent | 5aa0017e91cac135ef8b84c138becb09decb1d58 (diff) | |
download | volse-hubzilla-d5d67708ac912fa863a062e3469eb4ac17e84cdf.tar.gz volse-hubzilla-d5d67708ac912fa863a062e3469eb4ac17e84cdf.tar.bz2 volse-hubzilla-d5d67708ac912fa863a062e3469eb4ac17e84cdf.zip |
Alter the queue so that each queue item stores the scheduled time of the next delivery. This keeps the query for
queued items simple. We no longer group by posturl; as the queue update function will only keep one item per destination
scheduled for shorter term processing. Others (multiple queued items for a single destination) will be scheduled for
delivery far into the future and only delivered if the hub responds to the "active" or short term queue item.
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Daemon/Queue.php | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/Zotlabs/Daemon/Queue.php b/Zotlabs/Daemon/Queue.php index 27306589d..74541867c 100644 --- a/Zotlabs/Daemon/Queue.php +++ b/Zotlabs/Daemon/Queue.php @@ -61,30 +61,15 @@ class Queue { // the site is permanently down, there's no reason to attempt delivery at all, or at most not more than once // or twice a day. - // FIXME: can we sort postgres on outq_priority and maintain the 'distinct' ? - // The order by max(outq_priority) might be a dodgy query because of the group by. - // The desired result is to return a sequence in the order most likely to be delivered in this run. - // If a hub has already been sitting in the queue for a few days, they should be delivered last; - // hence every failure should drop them further down the priority list. - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $prefix = 'DISTINCT ON (outq_posturl)'; - $suffix = 'ORDER BY outq_posturl'; - } else { - $prefix = ''; - $suffix = 'GROUP BY outq_posturl ORDER BY max(outq_priority)'; - } - $r = q("SELECT $prefix * FROM outq WHERE outq_delivered = 0 and (( outq_created > %s - INTERVAL %s and outq_updated < %s - INTERVAL %s ) OR ( outq_updated < %s - INTERVAL %s )) $suffix", - db_utcnow(), db_quoteinterval('12 HOUR'), - db_utcnow(), db_quoteinterval('15 MINUTE'), - db_utcnow(), db_quoteinterval('1 HOUR') + $r = q("SELECT * FROM outq WHERE outq_delivered = 0 and outq_scheduled < '%s' ", + db_utcnow() ); } if(! $r) return; - foreach($r as $rr) { - queue_deliver($rr); + foreach($r as $rv) { + queue_deliver($rv); } } } |