X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2FTag.php;h=3020a2f2934839e0108779bda564314752e09bcb;hb=6dbbd081795fa1c8fe57db2248ac162efeeada88;hp=bfdafb947fd4739a90cb998625c939ea9b5b4ccb;hpb=5666866812dc5890106039f15049012c0ec34292;p=friendica.git
diff --git a/src/Model/Tag.php b/src/Model/Tag.php
index bfdafb947f..3020a2f293 100644
--- a/src/Model/Tag.php
+++ b/src/Model/Tag.php
@@ -1,6 +1,6 @@
' . htmlspecialchars($tag['name']) . '';
- $return['tags'][] = $prefix . '' . htmlspecialchars($tag['name']) . '';
+ $return['hashtags'][] = '' . $prefix . '' . htmlspecialchars($tag['name']) . '';
+ $return['tags'][] = '' . $prefix . '' . htmlspecialchars($tag['name']) . '';
break;
case self::MENTION:
case self::EXCLUSIVE_MENTION:
@@ -435,8 +436,8 @@ class Tag
} else {
$tag['url'] = Contact::magicLink($tag['url']);
}
- $return['mentions'][] = $prefix . '' . htmlspecialchars($tag['name']) . '';
- $return['tags'][] = $prefix . '' . htmlspecialchars($tag['name']) . '';
+ $return['mentions'][] = '' . $prefix . '' . htmlspecialchars($tag['name']) . '';
+ $return['tags'][] = '' . $prefix . '' . htmlspecialchars($tag['name']) . '';
break;
case self::IMPLICIT_MENTION:
$return['implicit_mentions'][] = $prefix . $tag['name'];
@@ -545,13 +546,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 +599,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);