Favorites not part of simulation, must implement plugin support

This commit is contained in:
Mikael Nordfeldth 2014-06-28 11:22:07 +02:00
parent fcdd061b4f
commit 04f60fd1d9

View File

@ -31,7 +31,7 @@ $longoptions = array(
'words=', 'words=',
'prefix=', 'prefix=',
'groupprefix=', 'groupprefix=',
'faves=' // 'faves=',
); );
$helptext = <<<END_OF_CREATESIM_HELP $helptext = <<<END_OF_CREATESIM_HELP
@ -40,7 +40,6 @@ Creates a lot of test users and notices to (loosely) simulate a real server.
-b --subscriptions Average subscriptions per user (default no. users/20) -b --subscriptions Average subscriptions per user (default no. users/20)
-g --groups Number of groups (default 20) -g --groups Number of groups (default 20)
-j --joins Number of groups per user (default 5) -j --joins Number of groups per user (default 5)
-f --faves Number of faves per user (default notices/10)
-n --notices Average notices per user (default 100) -n --notices Average notices per user (default 100)
-t --tags Number of distinct hash tags (default 10000) -t --tags Number of distinct hash tags (default 10000)
-u --users Number of users (default 100) -u --users Number of users (default 100)
@ -275,6 +274,7 @@ function newJoin($u, $g)
} }
} }
/* Plugins should be part of the simulation too!
function newFave($u) function newFave($u)
{ {
global $userprefix; global $userprefix;
@ -317,7 +317,7 @@ function newFave($u)
} }
Fave::addNew($user->getProfile(), $notice); Fave::addNew($user->getProfile(), $notice);
} }*/
function testNoticeContent() function testNoticeContent()
{ {
@ -344,7 +344,8 @@ function testNoticeContent()
return $text; return $text;
} }
function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesavg, $messageavg, $tagmax) //function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesavg, $messageavg, $tagmax)
function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $messageavg, $tagmax)
{ {
global $config; global $config;
$config['site']['dupelimit'] = -1; $config['site']['dupelimit'] = -1;
@ -372,7 +373,8 @@ function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesav
// # registrations + # notices + # subs // # registrations + # notices + # subs
$events = $usercount + $groupcount + ($usercount * ($noticeavg + $subsavg + $joinsavg + $favesavg + $messageavg)); //$events = $usercount + $groupcount + ($usercount * ($noticeavg + $subsavg + $joinsavg + $favesavg + $messageavg));
$events = $usercount + $groupcount + ($usercount * ($noticeavg + $subsavg + $joinsavg + $messageavg));
$events -= $preuser; $events -= $preuser;
$events -= $pregroup; $events -= $pregroup;
@ -382,7 +384,7 @@ function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesav
$nt = $gt + ($usercount * $noticeavg); $nt = $gt + ($usercount * $noticeavg);
$st = $nt + ($usercount * $subsavg); $st = $nt + ($usercount * $subsavg);
$jt = $st + ($usercount * $joinsavg); $jt = $st + ($usercount * $joinsavg);
$ft = $jt + ($usercount * $favesavg); // $ft = $jt + ($usercount * $favesavg);
$mt = $ft + ($usercount * $messageavg); $mt = $ft + ($usercount * $messageavg);
printfv("$events events ($ut, $gt, $nt, $st, $jt, $ft, $mt)\n"); printfv("$events events ($ut, $gt, $nt, $st, $jt, $ft, $mt)\n");
@ -408,9 +410,9 @@ function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesav
} else if ($e > $st && $e <= $jt) { } else if ($e > $st && $e <= $jt) {
printfv("$i Making a new group join\n"); printfv("$i Making a new group join\n");
newJoin($n, $g); newJoin($n, $g);
} else if ($e > $jt && $e <= $ft) { /* } else if ($e > $jt && $e <= $ft) {
printfv("$i Making a new fave\n"); printfv("$i Making a new fave\n");
newFave($n); newFave($n);*/
} else if ($e > $ft && $e <= $mt) { } else if ($e > $ft && $e <= $mt) {
printfv("$i Making a new message\n"); printfv("$i Making a new message\n");
newMessage($n); newMessage($n);
@ -427,7 +429,7 @@ $groupcount = (have_option('g', 'groups')) ? get_option_value('g', 'groups') :
$noticeavg = (have_option('n', 'notices')) ? get_option_value('n', 'notices') : 100; $noticeavg = (have_option('n', 'notices')) ? get_option_value('n', 'notices') : 100;
$subsavg = (have_option('b', 'subscriptions')) ? get_option_value('b', 'subscriptions') : max($usercount/20, 10); $subsavg = (have_option('b', 'subscriptions')) ? get_option_value('b', 'subscriptions') : max($usercount/20, 10);
$joinsavg = (have_option('j', 'joins')) ? get_option_value('j', 'joins') : 5; $joinsavg = (have_option('j', 'joins')) ? get_option_value('j', 'joins') : 5;
$favesavg = (have_option('f', 'faves')) ? get_option_value('f', 'faves') : max($noticeavg/10, 5); //$favesavg = (have_option('f', 'faves')) ? get_option_value('f', 'faves') : max($noticeavg/10, 5);
$messageavg = (have_option('m', 'messages')) ? get_option_value('m', 'messages') : max($noticeavg/10, 5); $messageavg = (have_option('m', 'messages')) ? get_option_value('m', 'messages') : max($noticeavg/10, 5);
$tagmax = (have_option('t', 'tags')) ? get_option_value('t', 'tags') : 10000; $tagmax = (have_option('t', 'tags')) ? get_option_value('t', 'tags') : 10000;
$userprefix = (have_option('x', 'prefix')) ? get_option_value('x', 'prefix') : 'testuser'; $userprefix = (have_option('x', 'prefix')) ? get_option_value('x', 'prefix') : 'testuser';
@ -445,7 +447,8 @@ if (is_readable($wordsfile)) {
} }
try { try {
main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesavg, $messageavg, $tagmax); //main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesavg, $messageavg, $tagmax);
main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $messageavg, $tagmax);
} catch (Exception $e) { } catch (Exception $e) {
printfv("Got an exception: ".$e->getMessage()); printfv("Got an exception: ".$e->getMessage());
} }