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

Allow filter feeds by network #81

Merged
merged 2 commits into from
Oct 15, 2021
Merged

Conversation

gabaldon
Copy link
Collaborator

  • Show select to filter feeds by network
  • Fix responsive

Comment on lines 52 to 60
let query
network !== 'all'
? (query = this.collection.find({
feedFullName: { $in: this.dataFeedsFullNames },
network
}))
: (query = this.collection.find({
feedFullName: { $in: this.dataFeedsFullNames }
}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a rule of thumb, ternaries shouldn't be used as a replacement for if/else statements, and they shouldn't have procedural code in them (e.g. variable binding / value assignment). They're better suited for expressions:

Suggested change
let query
network !== 'all'
? (query = this.collection.find({
feedFullName: { $in: this.dataFeedsFullNames },
network
}))
: (query = this.collection.find({
feedFullName: { $in: this.dataFeedsFullNames }
}))
// Base query will filter by allowed feed names.
// If a network is specified, the query will be refined to only include feeds for that network.
const baseQuery = { feedFullName: { $in: this.dataFeedsFullNames } }
const query = network === 'all' ? baseQuery : { ...baseQuery, network }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or for a mutable, simpler approach:

Suggested change
let query
network !== 'all'
? (query = this.collection.find({
feedFullName: { $in: this.dataFeedsFullNames },
network
}))
: (query = this.collection.find({
feedFullName: { $in: this.dataFeedsFullNames }
}))
// Base query will filter by allowed feed names.
// If a network is specified, the query will be refined to only include feeds for that network.
const query = { feedFullName: { $in: this.dataFeedsFullNames } }
if (network !== 'all') {
query['network'] = network
}

@gabaldon gabaldon merged commit f93a75b into witnet:main Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants