@method_decorator(catch_and_raise_exceptions)
    def get_total_row(self):
        def _clean_total_row(val, col):
            if isinstance(val, numbers.Number):
                return val
            elif col.calculate_total:
                return 0
            return ''

        def _get_relevant_column_ids(col, column_id_to_expanded_column_ids):
            return column_id_to_expanded_column_ids.get(col.column_id, [col.column_id])

        expanded_columns = get_expanded_columns(self.column_configs, self.config)

        qc = self.query_context()
        for c in self.columns:
            qc.append_column(c.view)

        session = connection_manager.get_scoped_session(self.engine_id)
        totals = qc.totals(
            session.connection(),
            [
                column_id
                for col in self.column_configs for column_id in _get_relevant_column_ids(col, expanded_columns)
                if col.calculate_total
            ],
            self.filter_values
        )

        total_row = [
            _clean_total_row(totals.get(column_id), col)
            for col in self.column_configs for column_id in _get_relevant_column_ids(
                col, expanded_columns
            )
        ]
        if total_row and total_row[0] is '':
            total_row[0] = ugettext('Total')
        return total_row
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/userreports/reports/data_source.py/ConfigurableReportDataSource.get_total_row/original