@detail_route()
    def usage(self, request, uuid):
        # XXX: Hack. Should be removed after zabbix refactoring
        if not ZABBIX_ENABLED:
            raise Http404()

        instance = self.get_object()

        if not instance.backend_id or instance.state in (models.Instance.States.PROVISIONING_SCHEDULED,
                                                         models.Instance.States.PROVISIONING):
            raise Http404()

        hour = 60 * 60
        now = time.time()
        data = {
            'start_timestamp': request.query_params.get('from', int(now - hour)),
            'end_timestamp': request.query_params.get('to', int(now)),
            'segments_count': request.query_params.get('datapoints', 6),
            'item': request.query_params.get('item'),
        }

        serializer = serializers.UsageStatsSerializer(data=data)
        serializer.is_valid(raise_exception=True)

        stats = serializer.get_stats([instance], is_paas=instance.type == models.Instance.Services.PAAS)
        # Hack that adds zero as start points
        created_ts = datetime_to_timestamp(instance.created)
        for stat in stats:
            if created_ts >= stat['from'] and stat['to'] - created_ts < hour / 2 and 'value' not in stat:
                stat['value'] = 0
        return Response(stats, status=status.HTTP_200_OK)
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/iaas/views.py/InstanceViewSet.usage/swapped operands of `>=`