Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

[Bug] ApplicationInsights/Query ignoring filters #394

Open
mokkrb opened this issue Mar 12, 2019 · 0 comments
Open

[Bug] ApplicationInsights/Query ignoring filters #394

mokkrb opened this issue Mar 12, 2019 · 0 comments

Comments

@mokkrb
Copy link

mokkrb commented Mar 12, 2019

Context:
I have added a new filter to my dasboard, and tried to apply it to my widgets.
When this filter is the only one applied to the query, everything works fine, but the issue comes when I add this filter to a previous one (so the widget would take 2 filters)

Here is an example of the query:

dataSources: [{
  id: "myId",
  type: "ApplicationInsights/Query",
  dependencies: {
    ...
  },
  params: {
    table: "myTable",
    queries: {
      query1: {
        query: () => `
            myQuery `,
        filters: [
          { dependency: "dep1",queryProperty: "field1" },
          { dependency: "dep2",queryProperty: "field2" }
        ]
      }
    }
  }
}]

Now looking at ApplicationInsights/Query, I found this piece of code:

// Apply selected filters to connected query
    filters.every((filter) => {
      const { dependency, queryProperty } = filter;
      const selectedFilters = dependencies[dependency] || [];
      if (selectedFilters.length > 0) {
        const f = 'where ' + selectedFilters.map((value) => `${queryProperty}=="${value}"`).join(' or ');
        q = isForked ? ` ${f} |\n ${q} ` : q.replace(/^(\s?\w+\s*?){1}(.)*/gim, '$1 | ' + f + ' $2');
        return true;
      }
      return false;
    });

which seems to be telling me that, if the first filter has not been selected, the return false; is executed, which will ignore the second filter, which might be set.

Possible solution:
moving every to forEach, or always use return true;?

Happy to make a PR for this one depending on feedbacks!

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

No branches or pull requests

1 participant