X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FTag.php;h=17a68f120f4b5ab643277ac387571410b6d93944;hb=48087136680d345e9222c974ae983262b319d308;hp=1bc700c3f14f0215643db0cb899bcdcf430d33c6;hpb=315dddbcb9232fea105d2da53ad2ba0e143bd7e4;p=friendica.git diff --git a/src/Model/Tag.php b/src/Model/Tag.php index 1bc700c3f1..17a68f120f 100644 --- a/src/Model/Tag.php +++ b/src/Model/Tag.php @@ -1,6 +1,6 @@ $uriid, 'hash' => $tags, 'callstack' => System::callstack()]); - if (!preg_match_all("/([" . $tags . "])\[url\=([^\[\]]*)\]([^\[\]]*)\[\/url\]/ism", $body, $result, PREG_SET_ORDER)) { + $result = self::getFromBody($body, $tags); + if (empty($result)) { return; } @@ -545,13 +564,21 @@ class Tag */ public static function setGlobalTrendingHashtags(int $period, int $limit = 10) { + // Get a uri-id that is at least X hours old. + // We use the uri-id in the query for the hash tags since this is much faster + $post = Post::selectFirstThread(['uri-id'], ["`uid` = ? AND `received` < ?", 0, DateTimeFormat::utc('now - ' . $period . ' hour')], + ['order' => ['received' => true]]); + if (empty($post['uri-id'])) { + return []; + } + $block_sql = self::getBlockedSQL(); $tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`, COUNT(DISTINCT(`author-id`)) as `authors` FROM `tag-search-view` - WHERE `private` = ? AND `uid` = ? AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR) $block_sql + WHERE `private` = ? AND `uid` = ? AND `uri-id` > ? $block_sql GROUP BY `term` ORDER BY `authors` DESC, `score` DESC LIMIT ?", - Item::PUBLIC, 0, $period, $limit); + Item::PUBLIC, 0, $post['uri-id'], $limit); if (DBA::isResult($tagsStmt)) { $tags = DBA::toArray($tagsStmt); @@ -590,13 +617,21 @@ class Tag */ public static function setLocalTrendingHashtags(int $period, int $limit = 10) { + // Get a uri-id that is at least X hours old. + // We use the uri-id in the query for the hash tags since this is much faster + $post = Post::selectFirstThread(['uri-id'], ["`uid` = ? AND `received` < ?", 0, DateTimeFormat::utc('now - ' . $period . ' hour')], + ['order' => ['received' => true]]); + if (empty($post['uri-id'])) { + return []; + } + $block_sql = self::getBlockedSQL(); $tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score`, COUNT(DISTINCT(`author-id`)) as `authors` FROM `tag-search-view` - WHERE `private` = ? AND `wall` AND `origin` AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR) $block_sql + WHERE `private` = ? AND `wall` AND `origin` AND `uri-id` > ? $block_sql GROUP BY `term` ORDER BY `authors` DESC, `score` DESC LIMIT ?", - Item::PUBLIC, $period, $limit); + Item::PUBLIC, $post['uri-id'], $limit); if (DBA::isResult($tagsStmt)) { $tags = DBA::toArray($tagsStmt);