Skip to content

Commit

Permalink
fix: BI-5620 notifications duplicates and cache fixes (#576)
Browse files Browse the repository at this point in the history
* notifications duplicates and cache fixes

* smol refactor
  • Loading branch information
juliarbkv authored Aug 15, 2024
1 parent 9fab45c commit 32d1dad
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/dl_api_lib/dl_api_lib/app/data_api/resources/dataset/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ async def prepare_dataset_for_request(
assert isinstance(services_registry, ApiServiceRegistry)
loader = DatasetApiLoader(service_registry=services_registry)

cached_dataset: Optional[Dataset] = None
with GenericProfiler("dataset-prepare"):
if enable_mutation_caching:
mutation_cache = self.try_get_cache(allow_slave=False)
Expand All @@ -289,14 +290,6 @@ async def prepare_dataset_for_request(
cached_dataset = await self.try_get_dataset_from_cache(mutation_cache, mutation_key)
if cached_dataset:
self.dataset = cached_dataset
update_info = loader.update_dataset_from_body(
dataset=self.dataset,
us_manager=us_manager,
dataset_data=req_model.dataset,
allow_rls_change=allow_rls_change,
)
await self.resolve_rls_groups_for_dataset(services_registry)
return update_info

update_info = loader.update_dataset_from_body(
dataset=self.dataset,
Expand All @@ -305,6 +298,11 @@ async def prepare_dataset_for_request(
allow_rls_change=allow_rls_change,
)
await self.resolve_rls_groups_for_dataset(services_registry)

if cached_dataset:
await self.check_for_notifications(services_registry, us_manager)
return update_info

await us_manager.load_dependencies(self.dataset)

services_registry = self.dl_request.services_registry
Expand All @@ -325,7 +323,7 @@ async def prepare_dataset_for_request(

async def check_for_notifications(self, services_registry: ApiServiceRegistry, us_manager: AsyncUSManager) -> None:
ds_lc_manager = us_manager.get_lifecycle_manager(self.dataset)
for conn_id in ds_lc_manager.collect_links().values():
for conn_id in set(ds_lc_manager.collect_links().values()):
try:
conn = us_manager.get_loaded_us_connection(conn_id)
except Exception:
Expand Down

0 comments on commit 32d1dad

Please sign in to comment.