Esempio n. 1
0
 def _get(self, service):
     tweets = []
     services = [service] if service else tweeter.SERVICES
     for service in services:
         tweets += self.tweet_manager.get(service)
     return encoding.to_json(
         {'messages': [encoding.to_dict(m) for m in tweets]})
    def _get(self, service):
        tweets = []
        services = [service] if service else tweeter.SERVICES
        for service in services:
            tweets += self.tweet_manager.get(service)

        return encoding.to_json({"messages": [encoding.to_dict(m) for m in tweets]})
    def _get(self):
        messages = {}  # messages by date + service

        for service in tweeter.SERVICES:
            tweet = self.tweet_manager.get_last_message(service)
            if tweet:
                if tweet.created_at < datetime.utcnow() - timedelta(days=1):
                    tweet = None
            messages[service] = encoding.to_dict(tweet) if tweet else None

        return encoding.to_json({"messages": messages})
Esempio n. 4
0
 def _get(self):
     raw = {
         'uptime': dict([(k, v) for k, v in self.uptime_manager.refresh()])
     }
     for service in tweeter.SERVICES:
         # if a service is UP and a tweet says it's down, then the down
         # takes precedence
         _s = raw['uptime'][service]
         if _s['status'] == 'UP':
             tweet_state = self.tweet_manager.get_latest_state(service)
             _s['status'] = tweet_state or _s['status']
     return encoding.to_json(raw)
Esempio n. 5
0
    def _get(self):
        messages = {}  # messages by date + service

        for service in tweeter.SERVICES:
            tweet = self.tweet_manager.get_last_message(service)
            if tweet:
                if tweet.created_at < datetime.utcnow() - timedelta(days=1):
                    tweet = None
            messages[service] = encoding.to_dict(tweet, ) if tweet else None

        return encoding.to_json({
            'messages': messages,
        })
    def _get(self):
        offset = int(self.request.get("offset", 0))
        max_date = datetime.utcnow() - timedelta(days=offset)
        min_date = max_date - timedelta(days=30)
        messages = defaultdict(list)  # messages by service
        messages["min"] = time.mktime(min_date.timetuple())
        messages["max"] = time.mktime(max_date.timetuple())

        for service in tweeter.SERVICES:
            tweets = self.tweet_manager.get_by_dates(service, max_date=max_date, min_date=min_date)
            tweets = [t for t in tweets]
            messages[service] = [encoding.to_dict(m) for m in reversed(tweets)]

        return encoding.to_json({"messages": messages})
    def _get(self):
        raw = {"uptime": dict([(k, v) for k, v in self.uptime_manager.refresh()])}

        for service in tweeter.SERVICES:
            # if a service is UP and a tweet says it's down, then the down
            # takes precedence
            _s = raw["uptime"][service]

            if _s["status"] == "UP":
                tweet_state = self.tweet_manager.get_latest_state(service)

                _s["status"] = tweet_state or _s["status"]

            subscription.should_notify(service, _s["status"], self.request.url)

        return encoding.to_json(raw)
 def _get(self):
     raw = {
         'uptime': dict([(k, v)
                         for k, v in
                         self.uptime_manager.refresh()])
     }
     for service in tweeter.SERVICES:
         # if a service is UP and a tweet says it's down, then the down
         # takes precedence
         _s = raw['uptime'][service]
         if _s['status'] == 'UP':
             tweet_state = self.tweet_manager.get_latest_state(
                 service
             )
             _s['status'] = tweet_state or _s['status']
     return encoding.to_json(raw)
Esempio n. 9
0
    def _get(self):
        raw = {
            'uptime': {}
        }

        for service in tweeter.SERVICES:
            # we need to have a state, so if we can't find one (e.g. because
            # the last tweet was a long time ago), default to UP
            tweet_state = self.tweet_manager.get_latest_state(service) or 'UP'

            raw['uptime'][service] = {
                'status': tweet_state,
                'uptime': self.tweet_manager.get_uptime_month(service)
            }

            subscription.should_notify(service, tweet_state, self.request.url)

        return encoding.to_json(raw)
Esempio n. 10
0
    def _get(self):
        uptimes = []
        for manager in self.uptime_managers:
            uptimes.extend(manager.refresh())
        raw = {'uptime': dict(uptimes)}

        for service in tweeter.SERVICES:
            # if a service is UP and a tweet says it's down, then the down
            # takes precedence
            _s = raw['uptime'][service]

            if _s['status'] == 'UP':
                tweet_state = self.tweet_manager.get_latest_state(service)

                _s['status'] = tweet_state or _s['status']

            subscription.should_notify(service, _s['status'], self.request.url)

        return encoding.to_json(raw)
Esempio n. 11
0
    def _get(self):
        offset = int(self.request.get('offset', 0))
        max_date = datetime.utcnow() - timedelta(days=offset)
        min_date = max_date - timedelta(days=30)
        messages = defaultdict(list)  # messages by service
        messages['min'] = time.mktime(min_date.timetuple())
        messages['max'] = time.mktime(max_date.timetuple())

        for service in tweeter.SERVICES:
            tweets = self.tweet_manager.get_by_dates(
                service,
                max_date=max_date,
                min_date=min_date,
            )
            tweets = [t for t in tweets]
            messages[service] = [encoding.to_dict(m) for m in reversed(tweets)]

        return encoding.to_json({
            'messages': messages,
        })
    def _get(self):
        uptimes = []
        for manager in self.uptime_managers:
            uptimes.extend(manager.refresh())
        raw = {
            'uptime': dict(uptimes)
        }

        for service in tweeter.SERVICES:
            # if a service is UP and a tweet says it's down, then the down
            # takes precedence
            _s = raw['uptime'][service]

            if _s['status'] == 'UP':
                tweet_state = self.tweet_manager.get_latest_state(
                    service
                )

                _s['status'] = tweet_state or _s['status']

            subscription.should_notify(service, _s['status'], self.request.url)

        return encoding.to_json(raw)
Esempio n. 13
0
    def _get(self):
        raw = {
            'uptime': dict([(k, v)
                            for k, v in
                            self.uptime_manager.refresh()])
        }
        for service in tweeter.SERVICES:
            # if a service is UP and a tweet says it's down, then the down
            # takes precedence
            _s = raw['uptime'][service]

            if _s['status'] == 'UP':
                tweet_state = self.tweet_manager.get_latest_state(
                    service
                )
                _s['status'] = tweet_state or _s['status']

            # This is filthy. Don't judge me bro
            if service == "DASH":
                service = "DASHBOARD"

            subscription.should_notify(service, _s['status'], self.request.url)

        return encoding.to_json(raw)