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

ClearData Emit action is missing case where the ClearData emit originates from within an object. #7947

Open
1 of 7 tasks
mudinthewater opened this issue Dec 9, 2024 · 1 comment · May be fixed by #7961
Open
1 of 7 tasks
Labels

Comments

@mudinthewater
Copy link

Summary

Emitting a ClearData from inside of a plugin at query does not trigger the corresponding clearSeries(); in MctPlot.vue for all plot types.

Expected vs Current Behavior

Current behavior does not check all cases when an object requests a clear to a plot.
For reference, here is the logic:

     compositionPathContainsId(domainObjectToFind) {
      if (!domainObjectToFind.composition) {
        return false;
      }

      return domainObjectToFind.composition.some((compositionIdentifier) => {
        return this.openmct.objects.areIdsEqual(
          compositionIdentifier,
          this.domainObject.identifier
        );
      });
    },
     clearData(domainObjectToClear) {
      // If we don't have an object to clear (global), or the IDs are equal, just clear the data.
      // If we have an object to clear, but the IDs don't match, we need to check the composition
      // of the object we've been asked to clear to see if it contains the id we're looking for.
      // This happens with stacked plots for example.
      // If we find the ID, clear the plot.
      if (
        !domainObjectToClear ||
        this.openmct.objects.areIdsEqual(
          domainObjectToClear.identifier,
          this.domainObject.identifier
        ) ||
        this.compositionPathContainsId(domainObjectToClear)
      ) {
        this.clearSeries();
      }
    },

I believe that there's either a missing case not captured by compositionPathContainsId, or compositionPathContainsId is just plain bugged. I'd also assert that the if statement checking if the requesting object has a composition was added later to mask an error caused by this bug, rather than fixing the bug, because a base telemetry object won't have a composition so it won't error out but it will also not clear the data.

Here's the logic a little more readable:

if no domain object (clear data)
else if the object requesting the clear is the same as the currently plotting object (clear data)
else if the object requesting the clear's composition contains the currently plotting object (clear data)

This third case seems to be checking the opposite of what its function name implies which is this, the missing case:
else if the object requesting the clear is within the composition of the currently plotting object (clear data)

Steps to Reproduce

  1. Add 'openmct.objectViews.emit('clearData',domainObject);'
    to the TelemetryMeanProvider. On every query, the mean must be cleared and recalculated otherwise it won't be accurate due to the 1-N sample window receiving more telemetry than the initial query.
  2. Create a new mean object and select it in the tree.
  3. Observe that if the object is plotted directly, clear->query->plot action is performed as expected. That is the first case above.
  4. Put the mean object into an overlay plot and zoom out. Observe that the plot is not cleared and requeried. That is case 4 above.

It is also exactly what case 3's function name describes:
compositionPathContainsId
The composition path (the overlay plot) contains the ID of the object requesting the clear. But it's not what the function does.

Environment

  • Open MCT Version:
  • Deployment Type:
  • OS:
  • Browser:

Impact Check List

  • Data loss or misrepresented data?
  • Regression? Did this used to work or has it always been broken?
  • Is there a workaround available?
  • Does this impact a critical component?
  • Is this just a visual bug with no functional impact?
  • Does this block the execution of e2e tests?
  • Does this have an impact on Performance?

Additional Information

@mudinthewater
Copy link
Author

mudinthewater commented Dec 9, 2024

Poked at this some more and suggest updating the vue implementation to this:

           compositionPathContainsId(domainObjectToFind) {
            if (!domainObjectToFind.composition) {
                return false;
            }

            return domainObjectToFind.composition.some((compositionIdentifier) => {
                return this.openmct.objects.areIdsEqual(compositionIdentifier, this.domainObject.identifier);
            });
        },
        plotCompositionContainsId(domainObjectToFind) {
            if (!this.domainObject.composition) {
                return false;
            }
            if (!domainObjectToFind.identifier){
                return false;
            }

            return this.domainObject.composition.some((compositionIdentifier) => {
                return this.openmct.objects.areIdsEqual(compositionIdentifier, domainObjectToFind.identifier);
            });
        },

        clearData(domainObjectToClear) {
            // If we don't have an object to clear (global), or the IDs are equal, just clear the data.
            // If we have an object to clear, but the IDs don't match, we need to check the composition
            // of the object we've been asked to clear to see if it contains the id we're looking for.
            // This happens with stacked plots for example.
            // If we find the ID, clear the plot.
            if (!domainObjectToClear
            || this.openmct.objects.areIdsEqual(domainObjectToClear.identifier, this.domainObject.identifier)
            || this.compositionPathContainsId(domainObjectToClear)
            || this.plotCompositionContainsId(domainObjectToClear))
            {
                this.clearSeries();
            }
        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant