From: Evan Prodromou <evan@status.net>
Date: Sat, 26 Mar 2011 19:36:47 +0000 (-0400)
Subject: fix off-by-one and more replies
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=841a9130e985ecdcb8accaa3826a9399f12af495;p=quix0rs-gnu-social.git

fix off-by-one and more replies
---

diff --git a/scripts/createsim.php b/scripts/createsim.php
index 46dc62d4ca..3244cda104 100644
--- a/scripts/createsim.php
+++ b/scripts/createsim.php
@@ -76,25 +76,26 @@ function newNotice($i, $tagmax)
     $n = rand(0, $i - 1);
     $user = User::staticGet('nickname', sprintf('%s%d', $userprefix, $n));
 
-    $is_reply = rand(0, 4);
+    $is_reply = rand(0, 1);
 
     $content = 'Test notice content';
 
     if ($is_reply == 0) {
-        $r = rand(0, max($i - 1, 0));
-        $rnick = sprintf('%s%d', $userprefix, $r);
-        $ruser = User::staticGet('nickname', $rnick);
         common_set_user($user);
-        $notices = $ruser->getNotices(0, 5);
+        $notices = $user->noticesWithFriends(0, 20);
         if ($notices->N > 0) {
-            $nval = rand(0, $notices->N);
+            $nval = rand(0, $notices->N - 1);
             $notices->fetch(); // go to 0th
             for ($i = 0; $i < $nval; $i++) {
                 $notices->fetch();
             }
             $options['reply_to'] = $notices->id;
+            $dont_use_nickname = rand(0, 2);
+            if ($dont_use_nickname != 0) {
+                $rprofile = $notices->getProfile();
+                $content = "@".$rprofile->nickname." ".$content;
+            }
         }
-        $content = "@$rnick " . $content;
     }
 
     $has_hash = rand(0, 2);
@@ -112,7 +113,7 @@ function newNotice($i, $tagmax)
     if ($in_group == 0) {
         $groups = $user->getGroups();
         if ($groups->N > 0) {
-            $gval = rand(0, $group->N);
+            $gval = rand(0, $group->N - 1);
             $groups->fetch(); // go to 0th
             for ($i = 0; $i < $gval; $i++) {
                 $groups->fetch();