src/Report/CwpStatsReport.php
public function sourceRecords($params = [], $sort = null, $limit = null)
    {
        $records = [];

        // Get the query to apply across all variants: looks at all subsites, translations, live stage only.
        $crossVariant = (function ($dataQuery) {
            $params = [
                'Subsite.filter' => false,
                'Versioned.mode' => 'stage',
                'Versioned.stage' => Versioned::LIVE,
            ];

            return $dataQuery->setDataQueryParam($params);
        });

        // Total.
        $records[] = [
            'Name' => _t(
                __CLASS__ . '.TotalPageCount',
                'Total live page count, across all translations and subsites'
            ),
            'Count' => $crossVariant(SiteTree::get())->count(),
        ];

        if (class_exists(Subsite::class)) {
            // Main site.
            $records[] = [
                'Name' => _t(__CLASS__ . '.PagesForMainSite', '- in the main site'),
                'Count' => $crossVariant(SiteTree::get())
                    ->filter(['SubsiteID' => 0])
                    ->count(),
            ];

            // Per subsite.
            $subsites = Subsite::get();
            foreach ($subsites as $subsite) {
                $records[] = [
                    'Name' => _t(
                        __CLASS__ . '.PagesForSubsite',
                        "- in the subsite '{SubsiteTitle}'",
                        ['SubsiteTitle' => $subsite->Title]
                    ),
                    'Count' => $crossVariant(SiteTree::get())
                        ->filter(['SubsiteID' => $subsite->ID])
                        ->count(),
                ];
            }
        }

        // Files.
        $records[] = [
            'Name' => _t(__CLASS__ . '.FileCount', 'File count'),
            'Count' => File::get()
                ->setDataQueryParam('Subsite.filter', false)
                ->filter(['ClassName:not' => Folder::class])
                ->count(),
        ];

        return ArrayList::create($records);
    }
public function sourceRecords($params = [], $sort = null, $limit = null)
    {
        $records = [];

        // Get the query to apply across all variants: looks at all subsites, translations, live stage only.
        $crossVariant = (function ($dataQuery) {
            $params = [
                'Subsite.filter' => false,
                'Versioned.mode' => 'stage',
                'Versioned.stage' => Versioned::LIVE,
            ];

            return $dataQuery->setDataQueryParam($params);
        });

        // Total.
        $records[] = [
            'Name' => _t(
                __CLASS__ . '.TotalPageCount',
                'Total live page count, across all translations and subsites'
            ),
            'Count' => $crossVariant(SiteTree::get())->count(),
        ];

        if (class_exists(Subsite::class)) {
            // Main site.
            $records[] = [
                'Name' => _t(__CLASS__ . '.PagesForMainSite', '- in the main site'),
                'Count' => $crossVariant(SiteTree::get())
                    ->filter(['SubsiteID' => 0])
                    ->count(),
            ];

            // Per subsite.
            $subsites = Subsite::get();
            foreach ($subsites as $subsite) {
                $records[] = [
                    'Name' => _t(
                        __CLASS__ . '.PagesForSubsite',
                        "- in the subsite '{SubsiteTitle}'",
                        ['SubsiteTitle' => $subsite->Title]
                    ),
                    'Count' => $crossVariant(SiteTree::get())
                        ->filter(['SubsiteID' => $subsite->ID])
                        ->count(),
                ];
            }
        }

        // Files.
        $records[] = [
            'Name' => _t(__CLASS__ . '.FileCount', 'File count'),
            'Count' => File::get()
                ->setDataQueryParam('Subsite.filter', false)
                ->filter(['ClassName:not' => Folder::class])
                ->count(),
        ];

        return ArrayList::create($records);
    }
public function sourceRecords ( $ params = [ ] , $ sort = null , $ limit = null ) { $ records = [ ] ; // Get the query to apply across all variants: looks at all subsites, translations, live stage only. $ crossVariant = ( function ( $ dataQuery ) { $ params = [ 'Subsite.filter' => false , 'Versioned.mode' => 'stage' , 'Versioned.stage' => Versioned :: LIVE , ] ; return $ dataQuery -> setDataQueryParam ( $ params ) ; } ) ; // Total. $ records [ ] = [ 'Name' => _t ( __CLASS__ . '.TotalPageCount' , 'Total live page count, across all translations and subsites' ) , 'Count' => $ crossVariant ( SiteTree :: get ( ) ) -> count ( ) , ] ; if ( class_exists ( Subsite :: class ) ) { // Main site. $ records [ ] = [ 'Name' => _t ( __CLASS__ . '.PagesForMainSite' , '- in the main site' ) , 'Count' => $ crossVariant ( SiteTree :: get ( ) ) -> filter ( [ 'SubsiteID' => 0 ] ) -> count ( ) , ] ; // Per subsite. $ subsites = Subsite :: get ( ) ; foreach ( $ subsites as $ subsite ) { $ records [ ] = [ 'Name' => _t ( __CLASS__ . '.PagesForSubsite' , "- in the subsite '{SubsiteTitle}'" , [ 'SubsiteTitle' => $ subsite -> Title ] ) , 'Count' => $ crossVariant ( SiteTree :: get ( ) ) -> filter ( [ 'SubsiteID' => $ subsite -> ID ] ) -> count ( ) , ] ; } } // Files. $ records [ ] = [ 'Name' => _t ( __CLASS__ . '.FileCount' , 'File count' ) , 'Count' => File :: get ( ) -> setDataQueryParam ( 'Subsite.filter' , false ) -> filter ( [ 'ClassName:not' => Folder :: class ] ) -> count ( ) , ] ; return ArrayList :: create ( $ records ) ; }
Manually create source records for the report. Agreggates cannot be provided as a column of a DataQuery result.

{@inheritDoc}
Manually create source records for the report . Agreggates cannot be provided as a column of a DataQuery result .