workfloworchestrator / orchestrator-core

The workflow orchestrator core repository
Apache License 2.0
45 stars 15 forks source link

Add depth recursion to inUseBySubscriptions and dependsOnSubscriptions #753

Closed tjeerddie closed 1 month ago

tjeerddie commented 1 month ago

This update introduces the ability to fetch subscription relations multiple layers deep by adding depth recursion to the subscription/s relations query.

Other changes:

More indepth description of the recursion feature:

For inUseBySubscriptions and dependsOnSubscriptions, the following filters were added:

SubscriptionRelationFilter:
    statuses: tuple[str, ...] | None = strawberry.field(default=None, description="Search by statuses")
    recurse_depth_limit: int = strawberry.field(default=10, description="the limited depth to recurse through")
    recurse_product_types: list[str] | None = strawberry.field(
        default=None, description="List of product types to recurse into"
    )

example query that would recurse through Test product type, more examples can be found in tests/unit_tests/graphql/test_subscription_relations.py:

query SubscriptionRelationsRecursive {
  subscriptions {
    page {
      subscriptionId
      description
      inUseBySubscriptions(
        inUseByFilter: {statuses: ["active"], recurseProductTypes: ["Test"]}
      ) {
        page {
          subscriptionId
          description
          status
        }
      }
    }
  }
}

The inUseByFilter/dependsOnFilter works in combination with filterBy and sortBy to filter and sort the recursively discovered subscriptions. For example:

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 96.15385% with 5 lines in your changes missing coverage. Please review.

Project coverage is 83.77%. Comparing base (34e4e5f) to head (a6d858a). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
orchestrator/services/subscription_relations.py 94.94% 3 Missing and 2 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #753 +/- ## ========================================== + Coverage 83.69% 83.77% +0.07% ========================================== Files 189 190 +1 Lines 9392 9432 +40 Branches 921 922 +1 ========================================== + Hits 7861 7902 +41 Misses 1280 1280 + Partials 251 250 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.