From 5b6dba66849f954676bf01caebc3c900ce4cf5bf Mon Sep 17 00:00:00 2001 From: "jocuri%softhome.net" Date: Fri, 27 Feb 2004 11:18:45 +0000 Subject: [PATCH] Patch for bug 192247: make Bugzilla quips truly random; code by Bill McGonigle ; r=bbaetz, justdave, a=justdave. --- webtools/bugzilla/buglist.cgi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webtools/bugzilla/buglist.cgi b/webtools/bugzilla/buglist.cgi index ab7373e06d9..d1a3c665bad 100755 --- a/webtools/bugzilla/buglist.cgi +++ b/webtools/bugzilla/buglist.cgi @@ -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();