Skip to content

Commit

Permalink
feat(filterUnusedVars): turns out this works great with the new subgr…
Browse files Browse the repository at this point in the history
…aph implementation so I removed the comment

also add the featureflag back to the feature
  • Loading branch information
asalem1 committed Jun 2, 2020
1 parent f04303e commit 8d087aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions ui/src/shared/utils/filterUnusedVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export const filterUnusedVars = (variables: Variable[], views: View[]) => {
(acc, vp) => [...acc, ...vp.queries.map(query => query.text)],
[] as Array<string>
)
// TODO: make sure to parse out variables for other used variables
// console.log('queryTexts: ', queryTexts)

const varsInUse = variables.filter(variable =>
queryTexts.some(text => isInQuery(text, variable))
Expand Down
6 changes: 3 additions & 3 deletions ui/src/variables/utils/hydrateVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const createVariableGraph = (
return Object.values(nodesByID)
}

export const isInQuery = (query: string, v: Variable) => {
export const isInQuery = (query: string, v: Variable): boolean => {
const regexp = new RegExp(
`${BOUNDARY_GROUP}${OPTION_NAME}.${v.name}${BOUNDARY_GROUP}`
)
Expand Down Expand Up @@ -194,6 +194,7 @@ const getDeduplicatedRootChild = (
- The node for one of the passed variables depends on this node
*/
// TODO(ariel): rename this back to findSubgraph & update tests once feature flag is removed
export const findSubgraphFeature = (
graph: VariableNode[],
variables: Variable[]
Expand Down Expand Up @@ -513,8 +514,7 @@ export const hydrateVars = (
options: HydrateVarsOptions
): EventedCancelBox<Variable[]> => {
let findSubgraphFunction = findSubgraph
if (true) {
// if (isFlagEnabled('hydratevars')) {
if (isFlagEnabled('hydratevars')) {
findSubgraphFunction = findSubgraphFeature
}

Expand Down

0 comments on commit 8d087aa

Please sign in to comment.