feat: add contribution operation and fix cache_key bug (#10286)

* feat: add contribution operation and fix cache_key_bug

* Add contribution schema
This commit is contained in:
Ville Brofeldt
2020-07-10 17:06:05 +03:00
committed by GitHub
parent 7d4d2e7469
commit 14260f9843
7 changed files with 124 additions and 7 deletions

View File

@@ -94,7 +94,7 @@ class QueryObject:
extras: Optional[Dict[str, Any]] = None,
columns: Optional[List[str]] = None,
orderby: Optional[List[List[str]]] = None,
post_processing: Optional[List[Dict[str, Any]]] = None,
post_processing: Optional[List[Optional[Dict[str, Any]]]] = None,
**kwargs: Any,
):
metrics = metrics or []
@@ -114,7 +114,9 @@ class QueryObject:
self.is_timeseries = is_timeseries
self.time_range = time_range
self.time_shift = utils.parse_human_timedelta(time_shift)
self.post_processing = post_processing or []
self.post_processing = [
post_proc for post_proc in post_processing or [] if post_proc
]
if not is_sip_38:
self.groupby = groupby or []
@@ -224,9 +226,9 @@ class QueryObject:
del cache_dict[k]
if self.time_range:
cache_dict["time_range"] = self.time_range
json_data = self.json_dumps(cache_dict, sort_keys=True)
if self.post_processing:
cache_dict["post_processing"] = self.post_processing
json_data = self.json_dumps(cache_dict, sort_keys=True)
return hashlib.md5(json_data.encode("utf-8")).hexdigest()
def json_dumps(self, obj: Any, sort_keys: bool = False) -> str: