Code Duplication    Length = 38-38 lines in 2 locations

code/reports/ForumReport.php 2 locations

@@ 15-52 (lines=38) @@
12
 * Lists the Number of people who have signed up in the past months categorized
13
 * by month.
14
 */
15
class ForumReport_MemberSignups extends SS_Report
16
{
17
18
    public function title()
19
    {
20
        return _t('Forum.FORUMSIGNUPS', 'Forum Signups by Month');
21
    }
22
23
    public function sourceRecords($params = array())
24
    {
25
        $membersQuery = new SQLQuery();
26
        $membersQuery->setFrom('"Member"');
27
        $membersQuery->setSelect(array(
28
            'Month' => DB::getConn()->formattedDatetimeClause('"Created"', '%Y-%m'),
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';
@@ 64-101 (lines=38) @@
61
 * Lists the Number of Posts made in the forums in the past months categorized
62
 * by month.
63
 */
64
class ForumReport_MonthlyPosts extends SS_Report
65
{
66
67
    public function title()
68
    {
69
        return _t('Forum.FORUMMONTHLYPOSTS', 'Forum Posts by Month');
70
    }
71
72
    public function sourceRecords($params = array())
73
    {
74
        $postsQuery = new SQLQuery();
75
        $postsQuery->setFrom('"Post"');
76
        $postsQuery->setSelect(array(
77
            'Month' => DB::getConn()->formattedDatetimeClause('"Created"', '%Y-%m'),
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';