equinor / fmu-sumo

Interaction with Sumo in the FMU context
https://fmu-sumo.readthedocs.io/en/latest/
Apache License 2.0
0 stars 5 forks source link

Add 'has' filter to CaseCollection #328

Closed rwiker closed 2 weeks ago

rwiker commented 2 weeks ago

Issue

325

Short description

  1. The CaseCollection constructor and the method CaseCollection.filter() have a new optional parameter called has. The filter() method generally returns a new CaseCollection instance; if has is specified, it is passed on to the constructor, which stores it in the member slot _has.
  2. All searches on a DocumentCollection involve the _next_batch()/_next_batch_async() methods. These methods are overridden by CaseCollection.
  3. _next_batch()/_next_batch_async() for CaseCollection checks if the member slot _has is set. If it is, we
    • Run a query to get all the values for fmu.case.uuid for the existing filters for the CaseCollection instance.
    • Create a new query that combines the value of _has with the set of values for fmu.case.uuid. Note: this new query applies to all object types, and not just case objects.
    • Retrieve all values for fmu.case.uuid for this new query.
    • Change the current filter for the CaseCollection instance to something like {"ids": {"values": <uuids>}}
    • Set the _hasmember attribute to None.
  4. After checking/handling the _has attribute, _next_batch()/_next_batch_async() passes control to the parent class implementation.

    Pre-review checklist

    • [ ] Read through all changes. No redundant print() statements, commented-out code, or other remnants from the development. ๐Ÿ‘€
    • [โœ…] Make sure tests pass after every commit. โœ…
    • [โœ…] New/refactored code is following same conventions as the rest of the code base. ๐Ÿงฌ
    • [โœ…] New/refactored code is tested. โš™
    • [โœ…] Documentation has been updated ๐Ÿงพ

Pre-merge checklist