# Path: slo_generator/constants.py
# NO_DATA = -1


import json
import logging
import pprint
import requests
from retrying import retry
from slo_generator.constants import NO_DATA

        Args:
            response (dict): Dynatrace API response.
            threshold (int): Threshold.
            good_below_threshold (bool): If true, good events are < threshold.

        Returns:
            tuple: Number of good events, Number of bad events.
        """
        try:
            datapoints = response['result'][0]['data']
            below = []
            above = []
            for point in datapoints:
                points_below = [
                    point for point in point['values']
                    if point is not None and point < threshold
                ]
                points_above = [
                    point for point in point['values']
                    if point is not None and point > threshold
                ]
                below.extend(points_below)
                above.extend(points_above)
            if good_below_threshold:
                return len(below), len(above)
            return len(above), len(below)
        except (IndexError, KeyError, ZeroDivisionError) as exception:
            LOGGER.warning("Couldn't find any values in timeseries response")
            LOGGER.debug(exception)

# Path: slo_generator/constants.py
# NO_DATA = -1


# Path: slo_generator/backends/dynatrace.py
import json
import logging
import pprint
import requests
from retrying import retry
from slo_generator.constants import NO_DATA


        Args:
            response (dict): Dynatrace API response.
            threshold (int): Threshold.
            good_below_threshold (bool): If true, good events are < threshold.

        Returns:
            tuple: Number of good events, Number of bad events.
        """
        try:
            datapoints = response['result'][0]['data']
            below = []
            above = []
            for point in datapoints:
                points_below = [
                    point for point in point['values']
                    if point is not None and point < threshold
                ]
                points_above = [
                    point for point in point['values']
                    if point is not None and point > threshold
                ]
                below.extend(points_below)
                above.extend(points_above)
            if good_below_threshold:
                return len(below), len(above)
            return len(above), len(below)
        except (IndexError, KeyError, ZeroDivisionError) as exception:
            LOGGER.warning("Couldn't find any values in timeseries response")
            LOGGER.debug(exception)

            return NO_DATA, NO_DATA  # no events in timeseries