Trending tags are now sort by different users

This commit is contained in:
Michael 2021-03-11 19:59:42 +00:00
parent b98405443e
commit 5666866812
4 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2021.03-rc (Red Hot Poker) -- 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`.`gravity` AS `gravity`,
`post-user`.`received` AS `received`, `post-user`.`received` AS `received`,
`post-user`.`network` AS `network`, `post-user`.`network` AS `network`,
`post-user`.`author-id` AS `author-id`,
`tag`.`name` AS `name` `tag`.`name` AS `name`
FROM `post-tag` FROM `post-tag`
INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid` INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`

View File

@ -547,10 +547,10 @@ class Tag
{ {
$block_sql = self::getBlockedSQL(); $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` FROM `tag-search-view`
WHERE `private` = ? AND `uid` = ? AND `received` > DATE_SUB(NOW(), INTERVAL ? HOUR) $block_sql 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); Item::PUBLIC, 0, $period, $limit);
if (DBA::isResult($tagsStmt)) { if (DBA::isResult($tagsStmt)) {
@ -592,10 +592,10 @@ class Tag
{ {
$block_sql = self::getBlockedSQL(); $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` 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 `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); Item::PUBLIC, $period, $limit);
if (DBA::isResult($tagsStmt)) { if (DBA::isResult($tagsStmt)) {

View File

@ -55,7 +55,7 @@
use Friendica\Database\DBA; use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1411); define('DB_UPDATE_VERSION', 1412);
} }
return [ return [

View File

@ -783,6 +783,7 @@
"gravity" => ["post-user", "gravity"], "gravity" => ["post-user", "gravity"],
"received" => ["post-user", "received"], "received" => ["post-user", "received"],
"network" => ["post-user", "network"], "network" => ["post-user", "network"],
"author-id" => ["post-user", "author-id"],
"name" => ["tag", "name"], "name" => ["tag", "name"],
], ],
"query" => "FROM `post-tag` "query" => "FROM `post-tag`