diff options
Diffstat (limited to 'redis/commands/timeseries')
-rw-r--r-- | redis/commands/timeseries/__init__.py | 11 | ||||
-rw-r--r-- | redis/commands/timeseries/commands.py | 35 | ||||
-rw-r--r-- | redis/commands/timeseries/info.py | 2 | ||||
-rw-r--r-- | redis/commands/timeseries/utils.py | 11 |
4 files changed, 17 insertions, 42 deletions
diff --git a/redis/commands/timeseries/__init__.py b/redis/commands/timeseries/__init__.py index 5ce538f..5b1f151 100644 --- a/redis/commands/timeseries/__init__.py +++ b/redis/commands/timeseries/__init__.py @@ -1,19 +1,12 @@ import redis.client -from .utils import ( - parse_range, - parse_get, - parse_m_range, - parse_m_get, -) -from .info import TSInfo from ..helpers import parse_to_list from .commands import ( ALTER_CMD, CREATE_CMD, CREATERULE_CMD, - DELETERULE_CMD, DEL_CMD, + DELETERULE_CMD, GET_CMD, INFO_CMD, MGET_CMD, @@ -24,6 +17,8 @@ from .commands import ( REVRANGE_CMD, TimeSeriesCommands, ) +from .info import TSInfo +from .utils import parse_get, parse_m_get, parse_m_range, parse_range class TimeSeries(TimeSeriesCommands): diff --git a/redis/commands/timeseries/commands.py b/redis/commands/timeseries/commands.py index 460ba76..c86e0b9 100644 --- a/redis/commands/timeseries/commands.py +++ b/redis/commands/timeseries/commands.py @@ -1,6 +1,5 @@ from redis.exceptions import DataError - ADD_CMD = "TS.ADD" ALTER_CMD = "TS.ALTER" CREATERULE_CMD = "TS.CREATERULE" @@ -58,7 +57,7 @@ class TimeSeriesCommands: - 'min': only override if the value is lower than the existing value. - 'max': only override if the value is higher than the existing value. When this is not set, the server-wide default will be used. - + For more information: https://oss.redis.com/redistimeseries/commands/#tscreate """ # noqa retention_msecs = kwargs.get("retention_msecs", None) @@ -81,7 +80,7 @@ class TimeSeriesCommands: For more information see The parameters are the same as TS.CREATE. - + For more information: https://oss.redis.com/redistimeseries/commands/#tsalter """ # noqa retention_msecs = kwargs.get("retention_msecs", None) @@ -129,7 +128,7 @@ class TimeSeriesCommands: - 'min': only override if the value is lower than the existing value. - 'max': only override if the value is higher than the existing value. When this is not set, the server-wide default will be used. - + For more information: https://oss.redis.com/redistimeseries/master/commands/#tsadd """ # noqa retention_msecs = kwargs.get("retention_msecs", None) @@ -276,13 +275,7 @@ class TimeSeriesCommands: """ # noqa return self.execute_command(DEL_CMD, key, from_time, to_time) - def createrule( - self, - source_key, - dest_key, - aggregation_type, - bucket_size_msec - ): + def createrule(self, source_key, dest_key, aggregation_type, bucket_size_msec): """ Create a compaction rule from values added to `source_key` into `dest_key`. Aggregating for `bucket_size_msec` where an `aggregation_type` can be @@ -321,11 +314,7 @@ class TimeSeriesCommands: """Create TS.RANGE and TS.REVRANGE arguments.""" params = [key, from_time, to_time] self._appendFilerByTs(params, filter_by_ts) - self._appendFilerByValue( - params, - filter_by_min_value, - filter_by_max_value - ) + self._appendFilerByValue(params, filter_by_min_value, filter_by_max_value) self._appendCount(params, count) self._appendAlign(params, align) self._appendAggregation(params, aggregation_type, bucket_size_msec) @@ -471,11 +460,7 @@ class TimeSeriesCommands: """Create TS.MRANGE and TS.MREVRANGE arguments.""" params = [from_time, to_time] self._appendFilerByTs(params, filter_by_ts) - self._appendFilerByValue( - params, - filter_by_min_value, - filter_by_max_value - ) + self._appendFilerByValue(params, filter_by_min_value, filter_by_max_value) self._appendCount(params, count) self._appendAlign(params, align) self._appendAggregation(params, aggregation_type, bucket_size_msec) @@ -654,7 +639,7 @@ class TimeSeriesCommands: return self.execute_command(MREVRANGE_CMD, *params) def get(self, key): - """ # noqa + """# noqa Get the last sample of `key`. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsget @@ -662,7 +647,7 @@ class TimeSeriesCommands: return self.execute_command(GET_CMD, key) def mget(self, filters, with_labels=False): - """ # noqa + """# noqa Get the last samples matching the specific `filter`. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsmget @@ -674,7 +659,7 @@ class TimeSeriesCommands: return self.execute_command(MGET_CMD, *params) def info(self, key): - """ # noqa + """# noqa Get information of `key`. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsinfo @@ -682,7 +667,7 @@ class TimeSeriesCommands: return self.execute_command(INFO_CMD, key) def queryindex(self, filters): - """ # noqa + """# noqa Get all the keys matching the `filter` list. For more information: https://oss.redis.com/redistimeseries/master/commands/#tsqueryindex diff --git a/redis/commands/timeseries/info.py b/redis/commands/timeseries/info.py index 2b8acd1..fba7f09 100644 --- a/redis/commands/timeseries/info.py +++ b/redis/commands/timeseries/info.py @@ -1,5 +1,5 @@ -from .utils import list_to_dict from ..helpers import nativestr +from .utils import list_to_dict class TSInfo: diff --git a/redis/commands/timeseries/utils.py b/redis/commands/timeseries/utils.py index c33b7c5..c49b040 100644 --- a/redis/commands/timeseries/utils.py +++ b/redis/commands/timeseries/utils.py @@ -2,9 +2,7 @@ from ..helpers import nativestr def list_to_dict(aList): - return { - nativestr(aList[i][0]): nativestr(aList[i][1]) - for i in range(len(aList))} + return {nativestr(aList[i][0]): nativestr(aList[i][1]) for i in range(len(aList))} def parse_range(response): @@ -16,9 +14,7 @@ def parse_m_range(response): """Parse multi range response. Used by TS.MRANGE and TS.MREVRANGE.""" res = [] for item in response: - res.append( - {nativestr(item[0]): - [list_to_dict(item[1]), parse_range(item[2])]}) + res.append({nativestr(item[0]): [list_to_dict(item[1]), parse_range(item[2])]}) return sorted(res, key=lambda d: list(d.keys())) @@ -34,8 +30,7 @@ def parse_m_get(response): res = [] for item in response: if not item[2]: - res.append( - {nativestr(item[0]): [list_to_dict(item[1]), None, None]}) + res.append({nativestr(item[0]): [list_to_dict(item[1]), None, None]}) else: res.append( { |