def aggregate(self, aggregates=None, drilldowns=None, cuts=None,
                  order=None, page=None, page_size=None, page_max=None):
        """Main aggregation function. This is used to compute a given set of
        aggregates, grouped by a given set of drilldown dimensions (i.e.
        dividers). The query can also be filtered and sorted. """

        def prep(cuts, drilldowns=False, aggregates=False, columns=None):
            q = select(columns)
            bindings = []
            cuts, q, bindings = Cuts(self).apply(q, bindings, cuts)

            attributes = None
            if drilldowns is not False:
                attributes, q, bindings = Drilldowns(self).apply(
                    q,
                    bindings,
                    drilldowns
                )

            if aggregates is not False:
                aggregates, q, bindings = Aggregates(self).apply(
                    q,
                    bindings,
                    aggregates
                )

            q = self.restrict_joins(q, bindings)
            return q, bindings, attributes, aggregates, cuts

        # Count
        count = count_results(self, prep(cuts,
                                         drilldowns=drilldowns,
                                         columns=[1])[0])

        # Summary
        summary = first_result(self, prep(cuts,
                                          aggregates=aggregates)[0].limit(1))

        # Results
        q, bindings, attributes, aggregates, cuts = \
            prep(cuts, drilldowns=drilldowns, aggregates=aggregates)
        page, q = Pagination(self).apply(q, page, page_size, page_max)
        ordering, q, bindings = Ordering(self).apply(q, bindings, order)
        q = self.restrict_joins(q, bindings)

        cells = list(generate_results(self, q))

        return {
            'total_cell_count': count,
            'cells': cells,
            'summary': summary,
            'cell': cuts,
            'aggregates': aggregates,
            'attributes': attributes,
            'order': ordering,
            'page': page['page'],
            'page_size': page['page_size']
        }
Main aggregation function. This is used to compute a given set of
        aggregates, grouped by a given set of drilldown dimensions (i.e.
        dividers). The query can also be filtered and sorted.