guardian icon indicating copy to clipboard operation
guardian copied to clipboard

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

Open mattsmithies opened this issue 1 year ago • 2 comments

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:

  • Linking to a policy in a dry run state
  • Creating new users
  • Auth as the new user
  • Assigning a user to a particular role
  • Submitting data to a specific block
  • Waiting a period of time (5 seconds) for Guardian to catch up
  • Auth as standard registry
  • Refresh data by fetching via tag
  • Set stateful filter
  • Fetch filtered block data

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 avatar May 08 '24 16:05 mattsmithies

@justin-atwell @prernaadev01 @anvabr

mattsmithies avatar May 08 '24 16:05 mattsmithies

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

mattsmithies avatar May 08 '24 16:05 mattsmithies