def build()

in lnt/server/reporting/summaryreport.py [0:0]


    def build(self):
        # Build a per-testsuite list of the machines that match the specified
        # patterns.
        def should_be_in_report(machine):
            if machine.name in self.report_machine_names:
                return True
            for rex in self.report_machine_rexes:
                if rex.match(machine.name):
                    return True
        self.requested_machines = dict((ts, filter(should_be_in_report,
                                                   ts.query(ts.Machine).all()))
                                       for ts in self.testsuites)
        self.requested_machine_ids = dict(
            (ts, [m.id for m in machines])
            for ts,machines in self.requested_machines.items())

        # First, collect all the runs to summarize on, for each index in the
        # report orders.
        self.runs_at_index = []
        for _,orders in self.report_orders:
            # For each test suite...
            runs = []
            for ts in self.testsuites:
                # Find all the orders that match.
                result = ts.query(ts.Order.id).\
                    filter(ts.Order.llvm_project_revision.in_(
                        orders)).all()
                ts_order_ids = [id for id, in result]

                # Find all the runs that matchs those orders.
                if not ts_order_ids:
                    ts_runs = []
                else:
                    ts_runs = ts.query(ts.Run).\
                        filter(ts.Run.order_id.in_(ts_order_ids)).\
                        filter(ts.Run.machine_id.in_(
                            self.requested_machine_ids[ts])).all()

                if not ts_runs:
                    self.warnings.append(
                        'no runs for test suite %r in orders %r' % (
                            ts.name, orders))
                        
                runs.append((ts_runs, ts_order_ids))
            self.runs_at_index.append(runs)

        # Load the tests for each testsuite.
        self.tests = dict((ts, dict((test.id, test)
                                    for test in ts.query(ts.Test)))
                          for ts in self.testsuites)

        # Compute the base table for aggregation.
        #
        # The table is indexed by a test name and test features, which are
        # either extracted from the test name or from the test run (depending on
        # the suite).
        #
        # Each value in the table contains a array with one item for each
        # report_order entry, which contains all of the samples for that entry..
        #
        # The table keys are tuples of:
        #  (<test name>,
        #   <metric>, # Value is either 'Compile Time' or 'Execution Time'.
        #   <arch>,
        #   <build mode>, # Value is either 'Debug' or 'Release'.
        #   <machine id>)

        self.data_table = {}
        self._build_data_table()

        # Compute indexed data table by applying the indexing functions.
        self._build_indexed_data_table()

        # Normalize across all machines.
        self._build_normalized_data_table()

        # Build final organized data tables.
        self._build_final_data_tables()