Replies: 1 comment 2 replies
-
I am very interested in this. Thank you for writing it up. I'd like to suggest a similar take, but slicing the abstraction differently, by field/property type/data type (am unsure of the vocabulary). Adding support for a new search typeFor each piece of data that might be present in a task, there is the possibility to use it in:
Currently, the code for that is spread around several places, and adding support for a new piece of data involves multiple edits in Query.ts, and also Sort.ts and soon Group.ts. For example, the way that in in Incomplete implementationsSome recent improvements have gone like this:
Common implementation detailsAlso, there will sometimes be code in common, for example, There is also a lot of duplicated code between the various date-based searches. SuggestionI'm imagining a file called something vaguely like
And maybe also things like:
These are just meant to be examples to try and convey the idea... I don't know for sure if the And of course all the date-based ones would have very little code, and where the only thing that would differ would be which field Example Benefits
|
Beta Was this translation helpful? Give feedback.
-
Following up from a discussion in a PR comment.
The Query class is getting bigger, and more filters are being added. How about we make a Query engine/factory and then register the filters with it based off a Filter class. Then we can pass in the query string and the factory will iterate through the registered filters to choose which to execute. This would probably also have a folder for all the filters to be in to make the codebase cleaner.
Taking this approach, the query engine could be used multiple times allowing grouping and by extension OR/AND based logic.
So, you would register a sub query filter which is a implementation of the engine which would return the set of tasks to pass on to the next filter to process based on this logic. There would be an AND filter and an OR filter in this case and then all data between the () would be passed in.
The refactor would mean the creation of Filters for each one we have in query already and the creation of the base class to inherit off.
Beta Was this translation helpful? Give feedback.
All reactions