hashgraph / guardian

The Guardian is an innovative open-source platform that streamlines the creation, management, and verification of digital environmental assets. It leverages a customizable Policy Workflow Engine and Web3 technology to ensure transparent and fraud-proof operations, making it a key tool for transforming sustainability practices and carbon markets.
Apache License 2.0
100 stars 129 forks source link

Refreshing of available filter state on Guardian (Potential Caching Issue) #3641

Open mattsmithies opened 5 months ago

mattsmithies commented 5 months ago

Problem description

The Guardian API seems to have a caching issue where data that has recently been pushed to a interfaceSourceDataBlock isn't filterable (if there is a filter block) connected to it.

When data is submitted to a block, within the context of using a filter to create a restful interface for Guardian the new data is not filtrable, unless the filter block itself is fetched to cache the new filterable values.

The API should be intelligent enough to know what values can be filtered upon, without the cache updated through a separate API call.

Step to reproduce

This issue is mitigated through the UI by default, it requires using the API directly.

More specifically:

Expected behavior

You should be able to filter data for a specific block without having to refresh the underlying data cache.

Screenshots

See loom: https://www.loom.com/share/768c25102ddd4e1086f2de43ecc4fc25

Example test code in my new client:

 it('A dry-run policy can create user, with a role, and submit project data -- read data from filter', function ($project) {
      $token = $this->helper->accessTokenForRegistry();
      $this->helper->setApiKey($token);

      $users = $this->dry_run_scenario->createUser();
      $user = (object) end($users);

      $this->dry_run_scenario->login($user->did);
      $this->policy_workflow->assignRole(GuardianRole::SUPPLIER);

      $document = json_decode($project, true);
      $uuid = $document['uuid'];

      $tag = "create_ecological_project";

      $sent_doc = $this->policy_workflow->sendDocumentToTag($tag, $document);

      // TODO: Use the listener/callback logic
      sleep(5);

      // As standard authority
      $this->dry_run_scenario->login($users[0]['did']);

      // refreshes tag (filter) -- strange
      $this->policy_workflow->dataByTag("supplier_grid_filter");

      // This is stateful
      $this->policy_workflow->filterByTag("supplier_grid_filter", $uuid);

      $supplier = $this->policy_workflow->dataByTagToBlock("supplier_grid");

      expect($supplier->uuid)->toBe($uuid);

      // $this->dry_run_scenario->restart();
      // $this->policy_mode->draft();
  });
mattsmithies commented 5 months ago

@justin-atwell @prernaadev01 @anvabr

mattsmithies commented 5 months ago

3610 this is somewhat related to the stateful call for filter usage, but extends it.