X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fpopularnoticesection.php;h=fbf9a60ab8112395156ffa26b9a5021293f816b6;hb=794fe16d691b61ef06df6bca0a580460eafa4931;hp=35b914a50c056303fe02222d3600f1837b7c8196;hpb=a08c76a4342cfb4b3d772f6880ba0b8f3153b246;p=quix0rs-gnu-social.git diff --git a/lib/popularnoticesection.php b/lib/popularnoticesection.php index 35b914a50c..fbf9a60ab8 100644 --- a/lib/popularnoticesection.php +++ b/lib/popularnoticesection.php @@ -48,17 +48,17 @@ class PopularNoticeSection extends NoticeSection { function getNotices() { + // @fixme there should be a common func for this if (common_config('db', 'type') == 'pgsql') { - $weightexpr='sum(exp(-extract(epoch from (now() - fave.modified)) / %s))'; if (!empty($this->out->tag)) { $tag = pg_escape_string($this->out->tag); } } else { - $weightexpr='sum(exp(-(now() - fave.modified) / %s))'; if (!empty($this->out->tag)) { $tag = mysql_escape_string($this->out->tag); } } + $weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff')); $qry = "SELECT notice.*, $weightexpr as weight "; if(isset($tag)) { $qry .= 'FROM notice_tag, notice JOIN fave ON notice.id = fave.notice_id ' . @@ -68,8 +68,9 @@ class PopularNoticeSection extends NoticeSection } $qry .= ' GROUP BY notice.id,notice.profile_id,notice.content,notice.uri,' . 'notice.rendered,notice.url,notice.created,notice.modified,' . - 'notice.reply_to,notice.is_local,notice.source,notice.conversation ' . - 'ORDER BY weight DESC'; + 'notice.reply_to,notice.is_local,notice.source,notice.conversation, ' . + 'notice.lat,notice.lon,location_id,location_ns' . + ' ORDER BY weight DESC'; $offset = 0; $limit = NOTICES_PER_SECTION + 1; @@ -77,7 +78,7 @@ class PopularNoticeSection extends NoticeSection $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; $notice = Memcached_DataObject::cachedQuery('Notice', - sprintf($qry, common_config('popular', 'dropoff')), + $qry, 1200); return $notice; }