aboutsummaryrefslogtreecommitdiffstats
path: root/include/taxonomy.php
diff options
context:
space:
mode:
authorHilmar R <u02@u29lx193>2021-02-28 21:06:16 +0100
committerHilmar R <u02@u29lx193>2021-03-01 18:48:11 +0100
commitc26dede97f626b52b7bf8962ed55d1dbda86abe8 (patch)
tree3c8c9bc97aa09f7ce9afe9bf467cf87bbf2c7d0b /include/taxonomy.php
parentea3390d626f85b7293a750958bfd1b5460958365 (diff)
downloadvolse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.gz
volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.bz2
volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.zip
get dev
Diffstat (limited to 'include/taxonomy.php')
-rw-r--r--include/taxonomy.php52
1 files changed, 27 insertions, 25 deletions
diff --git a/include/taxonomy.php b/include/taxonomy.php
index e06568d19..5fa4fde3f 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -345,7 +345,7 @@ function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) {
}
if($recent)
- $sql_extra .= " and item.created > '" . datetime_convert('UTC','UTC', 'now - ' . intval($recent) . ' days ') . "' ";
+ $sql_extra .= " and item.created > NOW() - INTERVAL " . db_quoteinterval(intval($recent) . ' DAY') . " ";
if($safemode) {
@@ -354,30 +354,32 @@ function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) {
$sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") ";
}
}
-
-
- $key = __FUNCTION__ . "-" . md5($site . $recent . $safemode . $limit . $type);
- $content = Cache::get($key, '1 MINUTE');
-
- if(! $content) {
- // Fetch tags
- $r = q("SELECT term, count(term) AS total FROM term LEFT JOIN item ON term.oid = item.id
- where term.ttype = %d
- and otype = %d and item_type = %d
- $sql_extra $uids $item_normal
- group by term order by total desc %s",
- intval($type),
- intval(TERM_OBJ_POST),
- intval(ITEM_TYPE_POST),
- ((intval($count)) ? "limit $count" : '')
- );
- } else
- $r = unserialize($content);
-
- if(! $r)
- return array();
- else
- Cache::set($key, serialize($r));
+
+ $key = __FUNCTION__ . "-" . md5($site . $recent . $safemode . $limit . $type);
+
+ $content = Cache::get($key, '5 MINUTE');
+ if(! $content) {
+
+ $content = Cache::get($key, '1 MONTH');
+ $arr = [
+ "SELECT term, count(term) AS total FROM term LEFT JOIN item ON term.oid = item.id
+ WHERE term.ttype = %d
+ AND otype = %d
+ AND item_type = %d
+ $sql_extra $uids $item_normal
+ GROUP BY term ORDER BY total DESC %s",
+ intval($type),
+ intval(TERM_OBJ_POST),
+ intval(ITEM_TYPE_POST),
+ (intval($count) ? "LIMIT $count" : '')
+ ];
+
+ \Zotlabs\Daemon\Master::Summon([ 'Cache_query', $key, base64_encode(json_encode($arr)) ]);
+ }
+
+ $r = unserialize($content);
+ if(! $r)
+ return [];
return Zotlabs\Text\Tagadelic::calc($r);
}