ForumReport_MemberSignups::group()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Forum Reports.
4
 * These are some basic reporting tools which sit in the CMS for the user to view.
5
 * No fancy graphing tools or anything just some simple querys and numbers
6
 *
7
 * @package forum
8
 */
9
10
/**
11
 * Member Signups Report.
12
 * Lists the Number of people who have signed up in the past months categorized
13
 * by month.
14
 */
15 View Code Duplication
class ForumReport_MemberSignups extends SS_Report
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
18
    public function title()
19
    {
20
        return _t('Forum.FORUMSIGNUPS', 'Forum Signups by Month');
21
    }
22
23
    public function sourceRecords($params = array())
0 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
    {
25
        $membersQuery = new SQLQuery();
0 ignored issues
show
Deprecated Code introduced by
The class SQLQuery has been deprecated with message: since version 4.0

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
26
        $membersQuery->setFrom('"Member"');
27
        $membersQuery->setSelect(array(
28
            'Month' => DB::getConn()->formattedDatetimeClause('"Created"', '%Y-%m'),
0 ignored issues
show
Deprecated Code introduced by
The method DB::getConn() has been deprecated with message: since version 4.0 Use DB::get_conn instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
29
            'Signups' => 'COUNT("Created")'
30
        ));
31
        $membersQuery->setGroupBy('"Month"');
32
        $membersQuery->setOrderBy('"Month"', 'DESC');
33
        $members = $membersQuery->execute();
34
35
        $output = ArrayList::create();
36
        foreach ($members as $member) {
37
            $member['Month'] = date('Y F', strtotime($member['Month']));
38
            $output->add(ArrayData::create($member));
39
        }
40
        return $output;
41
    }
42
43
    public function columns()
44
    {
45
        $fields = array(
46
            'Month' => 'Month',
47
            'Signups' => 'Signups'
48
        );
49
50
        return $fields;
51
    }
52
53
    public function group()
54
    {
55
        return 'Forum Reports';
56
    }
57
}
58
59
/**
60
 * Member Posts Report.
61
 * Lists the Number of Posts made in the forums in the past months categorized
62
 * by month.
63
 */
64 View Code Duplication
class ForumReport_MonthlyPosts extends SS_Report
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
{
66
67
    public function title()
68
    {
69
        return _t('Forum.FORUMMONTHLYPOSTS', 'Forum Posts by Month');
70
    }
71
72
    public function sourceRecords($params = array())
0 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
73
    {
74
        $postsQuery = new SQLQuery();
0 ignored issues
show
Deprecated Code introduced by
The class SQLQuery has been deprecated with message: since version 4.0

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
75
        $postsQuery->setFrom('"Post"');
76
        $postsQuery->setSelect(array(
77
            'Month' => DB::getConn()->formattedDatetimeClause('"Created"', '%Y-%m'),
0 ignored issues
show
Deprecated Code introduced by
The method DB::getConn() has been deprecated with message: since version 4.0 Use DB::get_conn instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
78
            'Posts' => 'COUNT("Created")'
79
        ));
80
        $postsQuery->setGroupBy('"Month"');
81
        $postsQuery->setOrderBy('"Month"', 'DESC');
82
        $posts = $postsQuery->execute();
83
84
        $output = ArrayList::create();
85
        foreach ($posts as $post) {
86
            $post['Month'] = date('Y F', strtotime($post['Month']));
87
            $output->add(ArrayData::create($post));
88
        }
89
        return $output;
90
    }
91
92
    public function columns()
93
    {
94
        $fields = array(
95
            'Month' => 'Month',
96
            'Posts' => 'Posts'
97
        );
98
99
        return $fields;
100
    }
101
102
    public function group()
103
    {
104
        return 'Forum Reports';
105
    }
106
}
107