]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Patch for bug 192247: make Bugzilla quips truly random; code by Bill McGonigle <bill...
authorjocuri%softhome.net <>
Fri, 27 Feb 2004 19:18:45 +0000 (19:18 +0000)
committerjocuri%softhome.net <>
Fri, 27 Feb 2004 19:18:45 +0000 (19:18 +0000)
buglist.cgi

index ab7373e06d99ff7e61ceba0bb4b25848001ff380..d1a3c665bada9729752f6fc5db485e15f1e4a706 100755 (executable)
@@ -199,7 +199,13 @@ sub GetQuip {
 
     my $quip;
 
-    SendSQL("SELECT quip FROM quips WHERE approved = 1 ORDER BY RAND() LIMIT 1");
+    # COUNT is quick because it is cached for MySQL. We may want to revisit
+    # this when we support other databases.
+
+    SendSQL("SELECT COUNT(quip) FROM quips WHERE approved = 1");
+    my $count = FetchOneColumn();
+    my $random = int(rand($count));
+    SendSQL("SELECT quip FROM quips WHERE approved = 1 LIMIT $random,1");
 
     if (MoreSQLData()) {
         ($quip) = FetchSQLData();