From f9745de11dfebb8ffa36eb9148295504fb947521 Mon Sep 17 00:00:00 2001 From: Andrei Markin Date: Thu, 11 Jun 2026 14:38:39 +0400 Subject: [PATCH] fix(core): include query_specification into cached reports * ensure that query specification is preserved when adding reports together --- libs/core/garf/core/__init__.py | 2 +- libs/core/garf/core/cache.py | 12 +++++++++--- libs/core/garf/core/report.py | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libs/core/garf/core/__init__.py b/libs/core/garf/core/__init__.py index 7188b243..ade3d1c8 100644 --- a/libs/core/garf/core/__init__.py +++ b/libs/core/garf/core/__init__.py @@ -26,4 +26,4 @@ 'ApiReportFetcher', ] -__version__ = '1.2.1' +__version__ = '1.2.2' diff --git a/libs/core/garf/core/cache.py b/libs/core/garf/core/cache.py index 6f839a06..69da6f96 100644 --- a/libs/core/garf/core/cache.py +++ b/libs/core/garf/core/cache.py @@ -83,7 +83,9 @@ def load( """ args_hash = args.hash if args else '' kwargs_hash = ( - hashlib.md5(json.dumps(kwargs).encode('utf-8'), usedforsecurity=False).hexdigest() + hashlib.md5( + json.dumps(kwargs).encode('utf-8'), usedforsecurity=False + ).hexdigest() if kwargs else '' ) @@ -96,7 +98,9 @@ def load( with open(cached_path, 'r', encoding='utf-8') as f: data = json.load(f) logger.debug('Report is loaded from cache: %s', str(cached_path)) - return report.GarfReport.from_json(json.dumps(data)) + loaded_report = report.GarfReport.from_json(json.dumps(data)) + loaded_report.query_specification = query + return loaded_report raise GarfCacheFileNotFoundError def save( @@ -117,7 +121,9 @@ def save( self.location.mkdir(parents=True, exist_ok=True) args_hash = args.hash if args else '' kwargs_hash = ( - hashlib.md5(json.dumps(kwargs).encode('utf-8'), usedforsecurity=False).hexdigest() + hashlib.md5( + json.dumps(kwargs).encode('utf-8'), usedforsecurity=False + ).hexdigest() if kwargs else '' ) diff --git a/libs/core/garf/core/report.py b/libs/core/garf/core/report.py index 78c2ef88..2ebd2178 100644 --- a/libs/core/garf/core/report.py +++ b/libs/core/garf/core/report.py @@ -423,8 +423,8 @@ def __add__(self, other: GarfReport) -> GarfReport: return GarfReport( results=self.results + other.results, column_names=self.column_names, - results_placeholder=self.results_placeholder - and other.results_placeholder, + results_placeholder=self.results_placeholder or other.results_placeholder, + query_specification=self.query_specification or other.query_specification, ) @classmethod