Merge pull request #1713 from annando/1506-ostatus-completion-timeframe

There is now two different checks for the completion of conversations
This commit is contained in:
fabrixxm 2015-06-30 08:36:33 +02:00
commit 7a0f2b61ab
2 changed files with 27 additions and 7 deletions

View file

@ -10,6 +10,7 @@ require_once("include/Photo.php");
define('OSTATUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
define('OSTATUS_DEFAULT_POLL_TIMEFRAME', 1440); // given in minutes
define('OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS', 14400); // given in minutes
function ostatus_fetchauthor($xpath, $context, $importer, &$contact) {
@ -475,7 +476,7 @@ function ostatus_convert_href($href) {
return $href;
}
function check_conversations($override = false) {
function check_conversations($mentions = false, $override = false) {
$last = get_config('system','ostatus_last_poll');
$poll_interval = intval(get_config('system','ostatus_poll_interval'));
@ -486,9 +487,16 @@ function check_conversations($override = false) {
if (($poll_interval < 0) AND !$override)
return;
$poll_timeframe = intval(get_config('system','ostatus_poll_timeframe'));
if (!$poll_timeframe)
$poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME;
if (!$mentions) {
$poll_timeframe = intval(get_config('system','ostatus_poll_timeframe'));
if (!$poll_timeframe)
$poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME;
} else {
$poll_timeframe = intval(get_config('system','ostatus_poll_timeframe'));
if (!$poll_timeframe)
$poll_timeframe = OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS;
}
if ($last AND !$override) {
$next = $last + ($poll_interval * 60);
@ -501,8 +509,16 @@ function check_conversations($override = false) {
logger('cron_start');
$start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60));
$conversations = q("SELECT `oid`, `url`, `uid` FROM `term` WHERE `type` = 7 AND `term` > '%s' GROUP BY `url`, `uid` ORDER BY `term` DESC",
dbesc($start));
if ($mentions)
$conversations = q("SELECT `term`.`oid`, `term`.`url`, `term`.`uid` FROM `term`
STRAIGHT_JOIN `thread` ON `thread`.`iid` = `term`.`oid` AND `thread`.`uid` = `term`.`uid`
WHERE `term`.`type` = 7 AND `term`.`term` > '%s' AND `thread`.`mention`
GROUP BY `term`.`url`, `term`.`uid` ORDER BY `term`.`term` DESC", dbesc($start));
else
$conversations = q("SELECT `oid`, `url`, `uid` FROM `term`
WHERE `type` = 7 AND `term` > '%s'
GROUP BY `url`, `uid` ORDER BY `term` DESC", dbesc($start));
foreach ($conversations AS $conversation) {
ostatus_completion($conversation['url'], $conversation['uid']);

View file

@ -103,7 +103,11 @@ function poller_run(&$argv, &$argc){
$abandon_days = 0;
// Check OStatus conversations
check_conversations();
// Check only conversations with mentions (for a longer time)
check_conversations(true);
// Check every conversation
check_conversations(false);
// To-Do: Regenerate usage statistics
// q("ANALYZE TABLE `item`");