Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mattsmithies opened this issue May 8, 2024 · 2 comments
Assignees
Labels
bug Something isn't working community

Comments

@mattsmithies
Copy link
Contributor

mattsmithies commented May 8, 2024

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
Copy link
Contributor Author

@mattsmithies
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community
Projects
None yet
Development

No branches or pull requests

4 participants