示例#1
0
 def _get_time_query_delete(begin, end):
     output = ""
     if begin:
         output += " WHERE time >= '{}'".format(utils.isotime(begin))
     if end:
         output += " AND " if output else " WHERE "
         output += "time < '{}'".format(utils.isotime(end))
     return output
示例#2
0
    def _build_dataframes(self, points):
        dataframes = {}
        for point in points:
            point_type = point['type']
            if point['time'] not in dataframes.keys():
                dataframes[point['time']] = {
                    'period': {
                        'begin': point['time'],
                        'end': utils.isotime(
                            utils.iso2dt(point['time'])
                            + datetime.timedelta(seconds=self._period)),
                    },
                    'usage': {},
                }
            usage = dataframes[point['time']]['usage']
            if point_type not in usage.keys():
                usage[point_type] = []
            usage[point_type].append(self._point_to_dataframe_entry(point))

        output = list(dataframes.values())
        output.sort(key=lambda x: x['period']['begin'])
        return output
示例#3
0
    def _build_dataframes(self, points):
        dataframes = {}
        for point in points:
            point_type = point['type']
            if point['time'] not in dataframes.keys():
                dataframes[point['time']] = {
                    'period': {
                        'begin': point['time'],
                        'end': utils.isotime(
                            utils.iso2dt(point['time'])
                            + datetime.timedelta(seconds=self._period)),
                    },
                    'usage': {},
                }
            usage = dataframes[point['time']]['usage']
            if point_type not in usage.keys():
                usage[point_type] = []
            usage[point_type].append(self._point_to_dataframe_entry(point))

        output = list(dataframes.values())
        output.sort(key=lambda x: x['period']['begin'])
        return output
示例#4
0
 def _get_time_query(begin, end):
     return " WHERE time >= '{}' AND time < '{}'".format(
         utils.isotime(begin), utils.isotime(end))
示例#5
0
 def __get_tag_or_field(point, key):
     if key == 'time':
         return utils.isotime(point['time'])
     return point['tags'].get(key) or point['fields'].get(key)
示例#6
0
 def __get_tag_or_field(point, key):
     if key == 'time':
         return utils.isotime(point['time'])
     return point['tags'].get(key) or point['fields'].get(key)
示例#7
0
 def _get_time_query(begin, end):
     return " WHERE time >= '{}' AND time < '{}'".format(
         utils.isotime(begin), utils.isotime(end))