X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fcreatesim.php;h=6cbb8c28aa406aa140cca13803495c44115e3c6e;hb=d11ce2ef3b7967dfe71e1f7b2eeb31f7d64618d6;hp=d5ed22758165a4eef35c25de47de9942985cdb26;hpb=f79aec36feaa4760201a7e88d5b31513a3c458ba;p=quix0rs-gnu-social.git diff --git a/scripts/createsim.php b/scripts/createsim.php index d5ed227581..6cbb8c28aa 100644 --- a/scripts/createsim.php +++ b/scripts/createsim.php @@ -31,7 +31,7 @@ $longoptions = array( 'words=', 'prefix=', 'groupprefix=', - 'faves=' +// 'faves=', ); $helptext = << sprintf('%s%d', $groupprefix, $i), 'local' => true, @@ -88,14 +87,14 @@ function newNotice($i, $tagmax) $options = array('scope' => Notice::defaultScope()); $n = rand(0, $i - 1); - $user = User::staticGet('nickname', sprintf('%s%d', $userprefix, $n)); + $user = User::getKV('nickname', sprintf('%s%d', $userprefix, $n)); $is_reply = rand(0, 1); $content = testNoticeContent(); if ($is_reply == 0) { - $stream = new InboxNoticeStream($user, $user->getProfile()); + $stream = new InboxNoticeStream($user->getProfile(), $user->getProfile()); $notices = $stream->getNotices(0, 20); if ($notices->N > 0) { $nval = rand(0, $notices->N - 1); @@ -118,7 +117,7 @@ function newNotice($i, $tagmax) $is_directed = rand(0, 4); if ($is_directed == 0) { - $subs = $user->getSubscriptions(0, 100)->fetchAll(); + $subs = $user->getSubscribed(0, 100)->fetchAll(); if (count($subs) > 0) { $seen = array(); $f = rand(0, 9); @@ -163,7 +162,7 @@ function newNotice($i, $tagmax) if ($in_group == 0) { $groups = $user->getGroups(); - if ($groups->N > 0) { + if ($groups instanceof User_group) { $gval = rand(0, $groups->N - 1); $groups->fetch(); // go to 0th for ($i = 0; $i < $gval; $i++) { @@ -192,7 +191,7 @@ function newMessage($i) global $userprefix; $n = rand(0, $i - 1); - $user = User::staticGet('nickname', sprintf('%s%d', $userprefix, $n)); + $user = User::getKV('nickname', sprintf('%s%d', $userprefix, $n)); $content = testNoticeContent(); @@ -216,7 +215,7 @@ function newSub($i) $fromnick = sprintf('%s%d', $userprefix, $f); - $from = User::staticGet('nickname', $fromnick); + $from = User::getKV('nickname', $fromnick); if (empty($from)) { throw new Exception("Can't find user '$fromnick'."); @@ -233,13 +232,13 @@ function newSub($i) $tunic = sprintf('%s%d', $userprefix, $t); - $to = User::staticGet('nickname', $tunic); + $to = User::getKV('nickname', $tunic); - if (empty($to)) { + if (!($to instanceof User)) { throw new Exception("Can't find user '$tunic'."); } - subs_subscribe_to($from, $to); + Subscription::start($from->getProfile(), $to->getProfile()); $from->free(); $to->free(); @@ -254,7 +253,7 @@ function newJoin($u, $g) $userNick = sprintf('%s%d', $userprefix, $userNumber); - $user = User::staticGet('nickname', $userNick); + $user = User::getKV('nickname', $userNick); if (empty($user)) { throw new Exception("Can't find user '$fromnick'."); @@ -264,7 +263,7 @@ function newJoin($u, $g) $groupNick = sprintf('%s%d', $groupprefix, $groupNumber); - $group = User_group::staticGet('nickname', $groupNick); + $group = User_group::getKV('nickname', $groupNick); if (empty($group)) { throw new Exception("Can't find group '$groupNick'."); @@ -275,6 +274,7 @@ function newJoin($u, $g) } } +/* Plugins should be part of the simulation too! function newFave($u) { global $userprefix; @@ -284,7 +284,7 @@ function newFave($u) $userNick = sprintf('%s%d', $userprefix, $userNumber); - $user = User::staticGet('nickname', $userNick); + $user = User::getKV('nickname', $userNick); if (empty($user)) { throw new Exception("Can't find user '$userNick'."); @@ -296,7 +296,7 @@ function newFave($u) $otherNick = sprintf('%s%d', $userprefix, $otherNumber); - $other = User::staticGet('nickname', $otherNick); + $other = User::getKV('nickname', $otherNick); if (empty($other)) { throw new Exception("Can't find user '$otherNick'."); @@ -317,7 +317,7 @@ function newFave($u) } Fave::addNew($user->getProfile(), $notice); -} +}*/ function testNoticeContent() { @@ -344,7 +344,8 @@ function testNoticeContent() 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; $config['site']['dupelimit'] = -1; @@ -372,7 +373,8 @@ function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesav // # 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 -= $pregroup; @@ -382,7 +384,7 @@ function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $favesav $nt = $gt + ($usercount * $noticeavg); $st = $nt + ($usercount * $subsavg); $jt = $st + ($usercount * $joinsavg); - $ft = $jt + ($usercount * $favesavg); +// $ft = $jt + ($usercount * $favesavg); $mt = $ft + ($usercount * $messageavg); 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) { printfv("$i Making a new group join\n"); newJoin($n, $g); - } else if ($e > $jt && $e <= $ft) { +/* } else if ($e > $jt && $e <= $ft) { printfv("$i Making a new fave\n"); - newFave($n); + newFave($n);*/ } else if ($e > $ft && $e <= $mt) { printfv("$i Making a new message\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; $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); +//$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); $tagmax = (have_option('t', 'tags')) ? get_option_value('t', 'tags') : 10000; $userprefix = (have_option('x', 'prefix')) ? get_option_value('x', 'prefix') : 'testuser'; @@ -445,7 +447,8 @@ if (is_readable($wordsfile)) { } 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) { printfv("Got an exception: ".$e->getMessage()); }