foreign key fields should not be filtered with blank/present operators
really fix it
use flat_map instead of map flatten
Remove (redundant) 'else nil'.
Clarify code paths and reduce repetition.
Introduce datetime_filter to DRY code.

Also clarified a few statements.
Moved association implementation details to its own class.
Extracted adapter statement building to class.
Made precompile asset list easier to read.
Reduce repetition and fix a couple of typos.
Reduced complexity of individual methods & split up responsibilities.
Allow Pry under test environment.
DRY up active_record adapter methods with WhereBuilder class.
Remove superfluous 'private' declaration.
The new StatementBuilder class enables to get rid of the block parameter in WhereBuilder.
Extracted some complexities into methods.
Add a class to clarify code around filtering duration.
Extracted 'viable model' search into a method.
Split ActiveRecord::StatementBuilder's build_statement_for_type method into multiple smaller methods for easier oversight and refactoring.
Split Mongoid::StatementBuilder's build_statement_for_type into multiple smaller methods.