Esempio n. 1
0
def test_overlapping_end():
    query_filter = OrFilter(fields=[
        _IntervalFilter('2018-02-08/2018-07-08'),
        _IntervalFilter('2018-07-08/2018-10-08'),
    ])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-02-08/2018-10-08'], tree_intervals)
Esempio n. 2
0
def test_or_disjoint():
    query_filter = OrFilter(fields=[
        _IntervalFilter('2018-02-08/2018-07-08'),
        _IntervalFilter('2019-02-08/2019-07-08'),
    ])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-02-08/2018-07-08', '2019-02-08/2019-07-08'], tree_intervals)
Esempio n. 3
0
def test_and_disjoint():
    query_filter = AndFilter(fields=[
        _IntervalFilter('2016-02-08/2016-07-08'),
        _IntervalFilter('2017-02-08/2017-07-08'),
        _IntervalFilter('2018-02-08/2018-07-08'),
    ])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert([], tree_intervals)
Esempio n. 4
0
def test_or_allows_all_time():
    query_filter = OrFilter(fields=[
        _IntervalFilter('2018-02-08/2018-07-08'),
        _IntervalFilter('2018-02-08/2018-07-08'),
        FieldFilter('hmis_indicator_0'),
    ])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert([], tree_intervals)
    _assert(True, tree.all_time)
Esempio n. 5
0
def test_and_complex():
    or_filter_1 = OrFilter(fields=[
        _IntervalFilter('2018-02-08/2018-07-08'),
        _IntervalFilter('2019-02-08/2019-07-08'),
    ])
    or_filter_2 = OrFilter(fields=[
        _IntervalFilter('2017-02-08/2018-07-08'),
        _IntervalFilter('2019-02-08/2019-07-08'),
    ])

    query_filter = AndFilter(fields=[or_filter_1, or_filter_2])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-02-08/2018-07-08', '2019-02-08/2019-07-08'], tree_intervals)
Esempio n. 6
0
def test_deeply_nested_and():
    query_filter = AndFilter(fields=[
        AndFilter(fields=[
            AndFilter(fields=[_IntervalFilter('2018-04-08/2019-07-08')]),
            _IntervalFilter('2018-01-01/2020-07-08'),
        ]),
        AndFilter(fields=[
            _IntervalFilter('2017-01-01/2018-09-12'),
            OrFilter(fields=[FieldFilter('hmis_indicator_0')]),
        ]),
    ])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-04-08/2018-09-12'], tree_intervals)
Esempio n. 7
0
def test_and_mixes_all_time():
    or_filter = OrFilter(fields=[
        _IntervalFilter('2018-02-08/2018-07-08'),
        _IntervalFilter('2018-02-08/2018-07-08'),
        FieldFilter('hmis_indicator_0'),
    ])
    and_filter = AndFilter(fields=[
        _IntervalFilter('2018-04-08/2019-07-08'),
        _IntervalFilter('2018-02-07/2018-06-08'),
    ])
    query_filter = AndFilter(fields=[or_filter, and_filter])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-04-08/2018-06-08'], tree_intervals)
Esempio n. 8
0
def test_and_unsatisfiable():
    or_filter_1 = OrFilter(fields=[
        _IntervalFilter('2018-02-08/2018-07-08'),
        _IntervalFilter('2019-02-08/2019-07-08'),
    ])
    or_filter_2 = OrFilter(fields=[
        _IntervalFilter('2017-02-08/2017-07-08'),
        _IntervalFilter('2019-12-08/2019-12-28'),
    ])

    query_filter = AndFilter(fields=[or_filter_1, or_filter_2])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert([], tree_intervals)
Esempio n. 9
0
def test_and_simple():
    query_filter = AndFilter(fields=[_IntervalFilter('2018-02-08/2018-07-08')])
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-02-08/2018-07-08'], tree_intervals)
Esempio n. 10
0
def test_simple():
    query_filter = _IntervalFilter('2018-02-08/2018-07-08')
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert(['2018-02-08/2018-07-08'], tree_intervals)
Esempio n. 11
0
def test_no_date_filter():
    query_filter = FieldFilter('hmis_indicator_0')
    tree = FilterTree(query_filter)
    tree_intervals = tree.to_druid_intervals()
    _assert([], tree_intervals)
    _assert(True, tree.all_time)
Esempio n. 12
0
 def build_intervals(self):
     tree = FilterTree(self.filter)
     if tree.all_time:
         time_boundary = current_app.druid_context.data_time_boundary
         return [time_boundary.get_full_time_interval()]
     return tree.to_druid_intervals()