Example #1
0
    def list_upcoming(cls, offset=0, limit=100):
        start = datetime.utcnow() - timedelta(minutes=10)
        # end = start + timedelta(minutes=30)
        num = 0
        thread_ids = []
        for talk in sorted(schedule.itervalues(), key=lambda x: (x['start'], x['room'])):
            if talk['end'] > start:  # and talk['start'] < end:
                thread_ids.append(talk['disqus:thread']['id'])
            if num > limit:
                return

        if not thread_ids:
            return []

        thread_ids = thread_ids[:limit]

        result = threads.get_many(thread_ids)
        missing_thread_ids = [t for t, v in result.iteritems() if not v]
        if missing_thread_ids:
            thread_list = disqusapi.threads.list(thread=missing_thread_ids, forum=app.config['DISQUS_FORUM'])
            for thread in thread_list:
                result[thread['id']] = Thread.save(thread)

        for thread in result.itervalues():
            if not thread:
                continue
            thread['session'] = schedule.get(thread.get('link'))

        return [result[t] for t in thread_ids if result.get(t)]
Example #2
0
    def list_upcoming(cls, offset=0, limit=100):
        start = datetime.utcnow() - timedelta(minutes=10)
        # end = start + timedelta(minutes=30)
        num = 0
        thread_ids = []
        for talk in sorted(schedule.itervalues(),
                           key=lambda x: (x['start'], x['room'])):
            if talk['end'] > start:  # and talk['start'] < end:
                thread_ids.append(talk['disqus:thread']['id'])
            if num > limit:
                return

        if not thread_ids:
            return []

        thread_ids = thread_ids[:limit]

        result = threads.get_many(thread_ids)
        missing_thread_ids = [t for t, v in result.iteritems() if not v]
        if missing_thread_ids:
            thread_list = disqusapi.threads.list(
                thread=missing_thread_ids, forum=app.config['DISQUS_FORUM'])
            for thread in thread_list:
                result[thread['id']] = Thread.save(thread)

        for thread in result.itervalues():
            if not thread:
                continue
            thread['session'] = schedule.get(thread.get('link'))

        return [result[t] for t in thread_ids if result.get(t)]
Example #3
0
    def list(cls, offset=0, limit=100):
        thread_ids = []
        for talk in sorted(schedule.itervalues(),
                           key=lambda x: (x['start'], x['room'])):
            thread_ids.append(talk['disqus:thread']['id'])

        if not thread_ids:
            return []

        thread_ids = thread_ids[:limit]

        result = threads.get_many(thread_ids)
        missing_thread_ids = [t for t, v in result.iteritems() if not v]
        if missing_thread_ids:
            thread_list = Paginator(disqusapi.threads.list,
                                    thread=missing_thread_ids,
                                    forum=app.config['DISQUS_FORUM'])
            for thread in thread_list:
                result[thread['id']] = Thread.save(thread)

        for thread in result.itervalues():
            if not thread:
                continue
            thread['session'] = schedule.get(thread.get('link'))

        return [result[t] for t in thread_ids if result.get(t)]
Example #4
0
    def list(cls, offset=0, limit=100):
        thread_ids = []
        for talk in sorted(schedule.itervalues(), key=lambda x: (x['start'], x['room'])):
            thread_ids.append(talk['disqus:thread']['id'])

        if not thread_ids:
            return []

        thread_ids = thread_ids[:limit]

        result = threads.get_many(thread_ids)
        missing_thread_ids = [t for t, v in result.iteritems() if not v]
        if missing_thread_ids:
            thread_list = Paginator(disqusapi.threads.list, thread=missing_thread_ids, forum=app.config['DISQUS_FORUM'])
            for thread in thread_list:
                result[thread['id']] = Thread.save(thread)

        for thread in result.itervalues():
            if not thread:
                continue
            thread['session'] = schedule.get(thread.get('link'))

        return [result[t] for t in thread_ids if result.get(t)]