Failed Conditions
Push — rbac ( be68b4...52c28b )
by Michael
03:11
created

StatsTemplateStats   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
eloc 36
c 0
b 0
f 0
dl 0
loc 40
ccs 0
cts 37
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A main() 0 38 1
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca\Pages\Statistics;
10
11
use PDO;
12
use Waca\Tasks\InternalPageBase;
13
14
class StatsTemplateStats extends InternalPageBase
15
{
16
    public function main()
17
    {
18
        $this->setHtmlTitle('Template Stats :: Statistics');
19
20
        $query = <<<SQL
21
SELECT
22
    t.id AS templateid,
23
    t.usercode AS usercode,
24
    u.count AS activecount,
25
    countall AS usercount
26
FROM welcometemplate t
27
    LEFT JOIN
28
    (
29
        SELECT
30
            welcome_template,
31
            COUNT(*) AS count
32
        FROM user
33
        WHERE
34
            (status = 'User' OR status = 'Admin')
35
            AND welcome_template IS NOT NULL
36
        GROUP BY welcome_template
37
    ) u ON u.welcome_template = t.id
38
    LEFT JOIN
39
    (
40
        SELECT
41
            welcome_template AS allid,
42
            COUNT(*) AS countall
43
        FROM user
44
        WHERE welcome_template IS NOT NULL
45
        GROUP BY welcome_template
46
    ) u2 ON u2.allid = t.id;
47
SQL;
48
        $database = $this->getDatabase();
49
        $statement = $database->query($query);
50
        $data = $statement->fetchAll(PDO::FETCH_ASSOC);
51
        $this->assign('dataTable', $data);
52
        $this->assign('statsPageTitle', 'Template Stats');
53
        $this->setTemplate('statistics/welcome-template-usage.tpl');
54
    }
0 ignored issues
show
Coding Style introduced by
Expected //end main()
Loading history...
55
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
56