-
-
Notifications
You must be signed in to change notification settings - Fork 249
Support attribute-level dependencies on item collections #1599
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
Conversation
dde6275 to
3566e3a
Compare
|
Sounds great!! I use this kind of stuff all the time 😅 Very much appreciated improvement proposal 👍 |
2830b6a to
637a1fa
Compare
352ce99 to
f40aa20
Compare
f40aa20 to
d4b3978
Compare
d4b3978 to
ea47861
Compare
|
Hi @denisdefreyne 👋 Do you plan to update this feature to stable anytime soon, not requiring the use of Thanks. |
|
Hey @opatry, thanks for the poke! This never got released because I ultimately wasn’t happy with how the Let me give this a bit more thought and I’ll follow up. |
|
Thanks for the update. I understand your ultimate goal. For the record, if it helps adding use cases, on my side I use: @items.select { |item| item.identifier =~ '/someprefix/**/*' }
@items.select { |item| item.identifier =~ '/someotherprefix/*' }
@items.select { |item| item.identifier =~ '/someotherprefix/blah-*' }
@items.select { |item| item[:extension] == 'md' }
@items.select { |item| %i[post page].include?(item[:kind]) }
@items.select { |item| item[:kind] == :page }Don't know if a |
|
For the first few use cases, there is @items.find_all('/someprefix/**/*')
@items.find_all('/someotherprefix/*')
@items.find_all('/someotherprefix/blah-*')
@items.find_all('/**/*.md')
|
|
This illustrates part of the problem, in fact: For example, it would be great to be able to do |
|
Having given this a bit more thought, I think it’d need to be able to chain queries, like |
Detailed description
This adds support for queries like
@items.where(kind: 'article'), which would return a collection of all items where thekindattribute is"article".In behavior, this is nearly identical to
@items.select { _1[:kind] == 'article' }, but is more friendly to the dependency tracker and outdatedness checker. For example:This creates only a single dependency, onto the item collection, rather than individual dependencies for each item. This cuts down on the number of dependencies. A lower number of dependencies means the dependency is smaller, and can be loaded/stored more quickly. For large sites, with many thousands of items, this can make a significant difference.
This prevents items from being marked outdated if their
kindattribute changes from something that isn’t"article"to something else that isn’t"article"either (e.g. from"note"to"thought"). This can reduce the number of redundant recompiles.For now, this feature is available only behind a feature flag. Set the
NANOC_FEATURESenvironment variable towhereto enable usage of.where(…). (Alternatively, set it toallto enable all feature flags.)To do
Related issues
n/a