Extracted some complexities into methods.
Add a class to clarify code around filtering duration.
Extracted 'viable model' search into a method.
refactor datetime_filter to be more abstract and taking less responsibilities.
pull up type based building of statement if common to all adapters, allow overriding if required.