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

Feature Request : Reusable Data Rule #321

Open
sbrickey opened this issue Apr 30, 2015 · 2 comments
Open

Feature Request : Reusable Data Rule #321

sbrickey opened this issue Apr 30, 2015 · 2 comments

Comments

@sbrickey
Copy link

In some pages, I reuse the same query on several views, all of which are added to the same page... this can lead to slow load times, and other DRY related problems when filters need to be adjusted.

It would be nice if I could create data rules/queries that are reusable in multiple views (Perhaps create GlobalDataRuleReference which refers to a DataRuleBase from some dev managed section of "global data rules"?).

Once defined and referenced, the results could be cached/reused for the life of the pageload (unless configured for caching).

EDITS:
2015/04/30 : 5:29PM UTC
As a step further, it'd also be nice to be able to ADD to the referenced data rule's query... example: global data rule for all blog articles that are Published... create another data rule (either in a view, or "globally") that sorts DESC by NumberOfTimesArticleHasBeenRead (the "reading" column in the sample site template) to show top 10 articles.

@MarkSizer
Copy link

You can already have data rules at the page level. These are processed once before any views are rendered. The outcome of the data rule is stored in the ViewBag and accessible by any views contained on that page. So if I understand correctly, there is already support for what you are requesting?

@sbrickey
Copy link
Author

so to give an example... blog posts... I have a view for listing, as well as a view for tags (a string field, not a category), and a view of links by month... three views... same data rule... those views are used on several pages, often with more than one on the same page.

in regards to being stored... when data rules are run (by the DataRuleExecutor), it does indeed check the viewbag... but only by the name of the rule... if those views use different names, it is not (immediately) skipped... in the case that the rule is not skipped, it will check the cache IF the rule is configured to use cache, AND if the PREVIOUS rules used cache (matches should occur regardless of rule names, since the cache key is the actual query logic).

So sure, if each view's data rules are created very carefully, in regards to others, it can reuse... but that's a lot of conditions to hit.

Plus, that doesn't address the value of DRY (Don't Repeat Yourself), and correctly applying changes (such as when I added future publishing to my blog posts, which required adding a filter to the data rules in each view).

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

No branches or pull requests

2 participants