From 5666866812dc5890106039f15049012c0ec34292 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 11 Mar 2021 19:59:42 +0000 Subject: [PATCH] Trending tags are now sort by different users --- database.sql | 3 ++- src/Model/Tag.php | 8 ++++---- static/dbstructure.config.php | 2 +- static/dbview.config.php | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/database.sql b/database.sql index 2e39b5a1d1..1c835587b1 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2021.03-rc (Red Hot Poker) --- DB_UPDATE_VERSION 1411 +-- DB_UPDATE_VERSION 1412 -- ------------------------------------------ @@ -2231,6 +2231,7 @@ CREATE VIEW `tag-search-view` AS SELECT `post-user`.`gravity` AS `gravity`, `post-user`.`received` AS `received`, `post-user`.`network` AS `network`, + `post-user`.`author-id` AS `author-id`, `tag`.`name` AS `name` FROM `post-tag` INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid` diff --git a/src/Model/Tag.php b/src/Model/Tag.php index c7155b5393..bfdafb947f 100644 --- a/src/Model/Tag.php +++ b/src/Model/Tag.php @@ -547,10 +547,10 @@ class Tag { $block_sql = self::getBlockedSQL(); - $tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score` + $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 - GROUP BY `term` ORDER BY `score` DESC LIMIT ?", + GROUP BY `term` ORDER BY `authors` DESC, `score` DESC LIMIT ?", Item::PUBLIC, 0, $period, $limit); if (DBA::isResult($tagsStmt)) { @@ -592,10 +592,10 @@ class Tag { $block_sql = self::getBlockedSQL(); - $tagsStmt = DBA::p("SELECT `name` AS `term`, COUNT(*) AS `score` + $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 - GROUP BY `term` ORDER BY `score` DESC LIMIT ?", + GROUP BY `term` ORDER BY `authors` DESC, `score` DESC LIMIT ?", Item::PUBLIC, $period, $limit); if (DBA::isResult($tagsStmt)) { diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 602e587c9e..5cbd7cd2be 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -55,7 +55,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1411); + define('DB_UPDATE_VERSION', 1412); } return [ diff --git a/static/dbview.config.php b/static/dbview.config.php index 17cadaba43..791665f734 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -783,6 +783,7 @@ "gravity" => ["post-user", "gravity"], "received" => ["post-user", "received"], "network" => ["post-user", "network"], + "author-id" => ["post-user", "author-id"], "name" => ["tag", "name"], ], "query" => "FROM `post-tag`