예제 #1
0
파일: episode.py 프로젝트: fk-lx/mygpo
def episodes_for_podcast_uncached(podcast, since=None, until={}, **kwargs):

    if not podcast:
        raise QueryParameterMissing('podcast')


    if kwargs.get('descending', False):
        since, until = until, since

    if isinstance(since, datetime):
        since = since.isoformat()

    if isinstance(until, datetime):
        until = until.isoformat()

    res = Episode.view('episodes/by_podcast',
            startkey     = [podcast.get_id(), since],
            endkey       = [podcast.get_id(), until],
            include_docs = True,
            reduce       = False,
            **kwargs
        )

    episodes = list(res)

    for episode in episodes:
        if episode.needs_update:
            incomplete_obj.send_robust(sender=episode)

    return episodes
예제 #2
0
파일: episode.py 프로젝트: fk-lx/mygpo
def episodes_for_slug(podcast_id, episode_slug):
    """ returns all episodes for the given slug

    this should normally only return one episode, but there might be multiple
    due to resolved replication conflicts, etc """

    if not podcast_id:
        raise QueryParameterMissing('podcast_id')

    if not episode_slug:
        raise QueryParameterMissing('episode_slug')

    r = Episode.view('episodes/by_slug',
            key          = [podcast_id, episode_slug],
            include_docs = True,
        )

    if not r:
        return []

    episodes = r.all()

    for episode in episodes:
        if episode.needs_update:
            incomplete_obj.send_robust(sender=episode)

    return episodes
예제 #3
0
파일: slugs.py 프로젝트: Mic92/mygpo
    def _get_existing_slugs(self):
        """ Episode slugs have to be unique within the Podcast """
        from mygpo.core.models import Episode

        res = Episode.view(
            "episodes/by_slug",
            startkey=[self.podcast_id, self.base_slug],
            endkey=[self.podcast_id, self.base_slug + "ZZZZZ"],
            wrap_doc=False,
        )
        return [r["key"][1] for r in res]
예제 #4
0
파일: episode.py 프로젝트: fk-lx/mygpo
def episode_slugs_per_podcast(podcast_id, base_slug):

    if not podcast_id:
        raise QueryParameterMissing('podcast_id')


    res = Episode.view('episodes/by_slug',
            startkey = [podcast_id, base_slug],
            endkey   = [podcast_id, base_slug + 'ZZZZZ'],
            wrap_doc = False,
        )
    return [r['key'][1] for r in res]
예제 #5
0
파일: episode.py 프로젝트: fk-lx/mygpo
def episodes_for_podcast_current(podcast, limit=None):

    if not podcast:
        raise QueryParameterMissing('podcast')

    res = Episode.view('episodes/by_podcast_current',
            startkey     = podcast.get_id(),
            endkey       = podcast.get_id(),
            include_docs = True,
            limit        = limit,
        )

    episodes = list(res)

    for episode in episodes:
        if episode.needs_update:
            incomplete_obj.send_robust(sender=episode)

    return episodes
예제 #6
0
파일: episode.py 프로젝트: fk-lx/mygpo
def episodes_by_id(episode_ids):

    if episode_ids is None:
        raise QueryParameterMissing('episode_ids')

    if not episode_ids:
        return []

    r = Episode.view('episodes/by_id',
            include_docs = True,
            keys         = episode_ids,
        )

    episodes = list(r)

    for episode in episodes:
        if episode.needs_update:
            incomplete_obj.send_robust(sender=episode)

    return episodes
예제 #7
0
파일: backend.py 프로젝트: Mic92/mygpo
def get_favorites(user):
    favorites = Episode.view("favorites/episodes_by_user", key=user._id, include_docs=True)
    return favorites