make tag dropoff configurable

darcs-hash:20080811175820-84dde-f3d934495fa90fadde5f7d5d0c37c5f2a575a9d8.gz
This commit is contained in:
Evan Prodromou 2008-08-11 13:58:20 -04:00
parent 12aba8ba32
commit 37c5e8ca3c
3 changed files with 8 additions and 3 deletions

View File

@ -21,7 +21,6 @@ if (!defined('LACONICA')) { exit(1); }
require_once(INSTALLDIR.'/actions/showstream.php'); require_once(INSTALLDIR.'/actions/showstream.php');
define('TAGS_PER_PAGE', 100); define('TAGS_PER_PAGE', 100);
define('AGE_FACTOR', 864000.0);
class TagAction extends StreamAction { class TagAction extends StreamAction {
@ -90,7 +89,7 @@ class TagAction extends StreamAction {
# This should probably be cached rather than recalculated # This should probably be cached rather than recalculated
$tags = DB_DataObject::factory('Notice_tag'); $tags = DB_DataObject::factory('Notice_tag');
$tags->selectAdd('max(notice_id) as last_notice_id'); $tags->selectAdd('max(notice_id) as last_notice_id');
$tags->selectAdd(sprintf('sum(exp(-(now() - created)/%f)) as weight', AGE_FACTOR)); $tags->selectAdd(sprintf('sum(exp(-(now() - created)/%f)) as weight', common_config('tag', 'dropoff')));
$tags->groupBy('tag'); $tags->groupBy('tag');
$tags->orderBy('weight DESC'); $tags->orderBy('weight DESC');

View File

@ -72,3 +72,7 @@ $config['db']['database'] = 'mysql://laconica:microblog@localhost/laconica';
#If you set this, you must run the xmppdaemon.php #If you set this, you must run the xmppdaemon.php
#as a daemon (with, say, start-stop-daemon) #as a daemon (with, say, start-stop-daemon)
#$config['queue']['enabled'] = true; #$config['queue']['enabled'] = true;
#exponential decay factor for tags, default 10 days
#raise this if traffic is slow, lower it if it's fast
#$config['tag']['dropoff'] = 86400.0 * 10;

View File

@ -85,6 +85,8 @@ $config =
'host' => NULL, # only set if != server 'host' => NULL, # only set if != server
'debug' => false, # print extra debug info 'debug' => false, # print extra debug info
'public' => array()), # JIDs of users who want to receive the public stream 'public' => array()), # JIDs of users who want to receive the public stream
'tag' =>
array('dropoff' => 864000.0),
); );
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options'); $config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');