Exemple #1
0
    def visit_specific_time_filter(self, node, children):
        # If we specify a specific date, it means any event on that day, and if
        # we specify a specific datetime then it means a few minutes interval
        # on either side of that datetime
        (search_key, _, date_value) = children
        if search_key.name not in self.date_keys:
            return self._handle_basic_filter(search_key, '=', SearchValue(date_value))

        try:
            from_val, to_val = parse_datetime_value(date_value)
        except InvalidQuery as exc:
            raise InvalidSearchQuery(exc.message)

        # TODO: Handle negations here. This is tricky because these will be
        # separate filters, and to negate this range we need (< val or >= val).
        # We currently AND all filters together, so we'll need extra logic to
        # handle. Maybe not necessary to allow negations for this.
        return [
            SearchFilter(
                search_key,
                '>=',
                SearchValue(from_val[0]),
            ),
            SearchFilter(
                search_key,
                '<',
                SearchValue(to_val[0]),
            ),
        ]
Exemple #2
0
    def visit_specific_time_filter(self, node, children):
        # If we specify a specific date, it means any event on that day, and if
        # we specify a specific datetime then it means a few minutes interval
        # on either side of that datetime
        (search_key, _, date_value) = children
        if search_key.name not in self.date_keys:
            return self._handle_basic_filter(search_key, '=', SearchValue(date_value))

        try:
            from_val, to_val = parse_datetime_value(date_value)
        except InvalidQuery as exc:
            raise InvalidSearchQuery(six.text_type(exc))

        # TODO: Handle negations here. This is tricky because these will be
        # separate filters, and to negate this range we need (< val or >= val).
        # We currently AND all filters together, so we'll need extra logic to
        # handle. Maybe not necessary to allow negations for this.
        return [
            SearchFilter(
                search_key,
                '>=',
                SearchValue(from_val[0]),
            ),
            SearchFilter(
                search_key,
                '<',
                SearchValue(to_val[0]),
            ),
        ]
Exemple #3
0
    def visit_specific_time_filter(self, node, children):
        # Note that this is a behaviour implemented for dates in our current
        # searches. If we specify a specific date, it means any event on that
        # day, and if we specify a specific datetime then it means a few minutes
        # interval on either side of that datetime
        search_key, _, date_value = children
        try:
            from_val, to_val = parse_datetime_value(date_value)
        except InvalidQuery as exc:
            raise InvalidSearchQuery(exc.message)

        # TODO: Handle negations here. This is tricky because these will be
        # separate filters, and to negate this range we need (< val or >= val).
        # We currently AND all filters together, so we'll need extra logic to
        # handle. Maybe not necessary to allow negations for this.
        return [
            SearchFilter(
                search_key,
                '>=',
                SearchValue(from_val[0]),
            ),
            SearchFilter(
                search_key,
                '<',
                SearchValue(to_val[0]),
            ),
        ]
Exemple #4
0
    def visit_specific_time_filter(self, node, children):
        # Note that this is a behaviour implemented for dates in our current
        # searches. If we specify a specific date, it means any event on that
        # day, and if we specify a specific datetime then it means a few minutes
        # interval on either side of that datetime
        search_key, _, date_value = children
        try:
            from_val, to_val = parse_datetime_value(date_value)
        except InvalidQuery as exc:
            raise InvalidSearchQuery(exc.message)

        return [
            SearchFilter(
                search_key,
                '>=',
                SearchValue(from_val[0]),
            ),
            SearchFilter(
                search_key,
                '<',
                SearchValue(to_val[0]),
            ),
        ]
Exemple #5
0
            return SearchFilter(search_key, operator,
                                SearchValue(search_value))
        else:
            return self._handle_basic_filter(search_key, '=',
                                             SearchValue(value.text))

    def visit_specific_time_filter(self, node, (search_key, _, date_value)):
        # If we specify a specific date, it means any event on that day, and if
        # we specify a specific datetime then it means a few minutes interval
        # on either side of that datetime
        if search_key.name not in self.date_keys:
            return self._handle_basic_filter(search_key, '=',
                                             SearchValue(date_value))

        try:
            from_val, to_val = parse_datetime_value(date_value)
        except InvalidQuery as exc:
            raise InvalidSearchQuery(exc.message)

        # TODO: Handle negations here. This is tricky because these will be
        # separate filters, and to negate this range we need (< val or >= val).
        # We currently AND all filters together, so we'll need extra logic to
        # handle. Maybe not necessary to allow negations for this.
        return [
            SearchFilter(
                search_key,
                '>=',
                SearchValue(from_val[0]),
            ),
            SearchFilter(
                search_key,