2005-08-18 01:23:48 +04:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is Litmus.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Zach Lipton <zach@zachlipton.com>
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use Litmus;
|
|
|
|
use Litmus::Error;
|
|
|
|
use Litmus::DB::Product;
|
|
|
|
|
|
|
|
use CGI;
|
|
|
|
use Time::Piece::MySQL;
|
|
|
|
|
|
|
|
my $c = new CGI;
|
|
|
|
|
|
|
|
print $c->header();
|
|
|
|
|
2005-08-18 01:36:19 +04:00
|
|
|
# find the number of testcases in the database
|
2005-08-18 03:35:30 +04:00
|
|
|
my $numtests = Litmus::DB::Test->count_all();
|
2005-08-18 01:36:19 +04:00
|
|
|
|
|
|
|
# find the number of users in the database
|
2005-08-18 03:35:30 +04:00
|
|
|
my $numusers = Litmus::DB::User->count_all();
|
2005-08-18 01:36:19 +04:00
|
|
|
|
2005-08-18 01:23:48 +04:00
|
|
|
# get a list of the top 15 testers of all time, sorted by the number
|
|
|
|
# of test results submitted:
|
2005-08-18 03:35:30 +04:00
|
|
|
my $dbh = Litmus::DB::User->db_Main();
|
|
|
|
my $sth = $dbh->prepare("SELECT userid, email, count(*) AS thecount
|
2005-08-18 01:36:19 +04:00
|
|
|
FROM users, testresults
|
|
|
|
WHERE
|
|
|
|
users.userid=testresults.user
|
|
|
|
GROUP BY user
|
2005-08-18 03:35:30 +04:00
|
|
|
ORDER BY thecount DESC
|
2005-08-18 01:36:19 +04:00
|
|
|
LIMIT 15;");
|
2005-08-18 03:35:30 +04:00
|
|
|
$sth->execute();
|
2005-08-18 01:23:48 +04:00
|
|
|
my @toptesters;
|
2005-08-18 03:35:30 +04:00
|
|
|
my @curtester;
|
|
|
|
while (@curtester = $sth->fetchrow_array()) {
|
2005-08-18 01:36:19 +04:00
|
|
|
my %testerinfo;
|
2005-08-18 03:35:30 +04:00
|
|
|
$testerinfo{"email"} = $curtester[1];
|
|
|
|
$testerinfo{"numtests"} = $curtester[2];
|
2005-08-18 01:36:19 +04:00
|
|
|
push(@toptesters, \%testerinfo);
|
2005-08-18 01:23:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
my $vars = {
|
2005-08-18 01:36:19 +04:00
|
|
|
numtests => $numtests,
|
|
|
|
numusers => $numusers,
|
|
|
|
toptesters => \@toptesters,
|
2005-08-18 01:23:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
Litmus->template()->process("stats/stats.html.tmpl", $vars) ||
|
|
|
|
internalError(Litmus->template()->error());
|
|
|
|
|