diff --git a/scripts/createsim.php b/scripts/createsim.php index 21ed38fd56..828706401d 100644 --- a/scripts/createsim.php +++ b/scripts/createsim.php @@ -30,7 +30,8 @@ $longoptions = array( 'users=', 'words=', 'prefix=', - 'groupprefix' + 'groupprefix=', + 'faves=' ); $helptext = <<getNotices()->fetchAll(); + + if (count($notices) == 0) { + return; + } + + $idx = rand(0, count($notices) - 1); + + $notice = $notices[$idx]; + + if ($user->hasFave($notice)) { + return; + } + + Fave::addNew($user->getProfile(), $notice); +} + function testNoticeContent() { global $words; @@ -243,7 +289,7 @@ function testNoticeContent() return $text; } -function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax) +function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesavg, $tagmax) { global $config; $config['site']['dupelimit'] = -1; @@ -271,7 +317,7 @@ function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax) // # registrations + # notices + # subs - $events = $usercount + $groupcount + ($usercount * ($noticeavg + $subsavg + $joinsavg)); + $events = $usercount + $groupcount + ($usercount * ($noticeavg + $subsavg + $joinsavg + $favesavg)); $events -= $preuser; $events -= $pregroup; @@ -281,8 +327,9 @@ function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax) $nt = $gt + ($usercount * $noticeavg); $st = $nt + ($usercount * $subsavg); $jt = $st + ($usercount * $joinsavg); + $ft = $jt + ($usercount * $favesavg); - printfv("$events events ($ut, $gt, $nt, $st, $jt)\n"); + printfv("$events events ($ut, $gt, $nt, $st, $jt, $ft)\n"); for ($i = 0; $i < $events; $i++) { @@ -305,6 +352,9 @@ function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax) } else if ($e > $st && $e <= $jt) { printfv("$i Making a new group join\n"); newJoin($n, $g); + } else if ($e > $jt && $e <= $ft) { + printfv("$i Making a new fave\n"); + newFave($n); } else { printfv("No event for $i!"); } @@ -318,6 +368,7 @@ $groupcount = (have_option('g', 'groups')) ? get_option_value('g', 'groups') : $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); $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); $tagmax = (have_option('t', 'tags')) ? get_option_value('t', 'tags') : 10000; $userprefix = (have_option('x', 'prefix')) ? get_option_value('x', 'prefix') : 'testuser'; $groupprefix = (have_option('z', 'groupprefix')) ? get_option_value('z', 'groupprefix') : 'testgroup'; @@ -334,7 +385,7 @@ if (is_readable($wordsfile)) { } try { - main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax); + main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesavg, $tagmax); } catch (Exception $e) { printfv("Got an exception: ".$e->getMessage()); }