Esempio n. 1
0
 def values(tags, after):
     sd_id = dataseries.SeriesDef.select_id_or_insert(
         cd.report.report_id, tags,
         dataseries.guess_series_spec(cd.report, cd.instances[0], 0, 0))
     sd = dataseries.SeriesDef.select(cd.report.report_id, tags, sd_id)
     res = dataseries.get_series_values_after(sd, cd.report, after)
     return [sv.value for sv in res]
Esempio n. 2
0
    def _set_series_data(self,
                         data,
                         from_dt=None,
                         to_dt=None,
                         after=None,
                         limit=None):
        data['series_data'] = []

        series_def_list = dataseries.SeriesDef.select_multi(
            self.tile.report_id,
            [(self.tile.tags, sc['series_id'])
             for sc in self.tile_options['series_configs']])

        latest_instance_id = self.tile.report.fetch_latest_instance_id(
            self.tile.tags)

        for series_def, series_config in zip(
                series_def_list, self.tile_options['series_configs']):
            if not series_def:
                log.warn(
                    'tile_data: series_def does not exist for report_id=%s series_config=%s',
                    self.tile.report_id, series_config)
                continue

            if from_dt is not None or to_dt is not None:
                rows = dataseries.get_series_values(
                    series_def,
                    self.tile.report,
                    data['fetched_from_dt'],
                    data['fetched_to_dt'],
                    limit=limit or mqeconfig.MAX_SERIES_POINTS_IN_TILE,
                    latest_instance_id=latest_instance_id)
            else:
                assert after is not None
                rows = dataseries.get_series_values_after(
                    series_def,
                    self.tile.report,
                    after,
                    limit or mqeconfig.MAX_SERIES_POINTS_IN_TILE,
                    latest_instance_id=latest_instance_id)

            value_list = []
            common_header = CommonValue()
            for row in rows:
                value_list.append(DataPoint.from_series_value(row))
                if row.header:
                    common_header.present(row.header)

            data['series_data'].append({
                'series_id':
                series_def.series_id,
                'name':
                series_def.series_spec.name(True),
                'data_points':
                value_list,
                'common_header':
                common_header.value,
            })