示例#1
0
文件: tasks.py 项目: 4johndoe/mygpo
def update_related_podcasts(podcast, max_related=20):
    get_podcast = itemgetter(0)

    related = calc_similar_podcasts(podcast)[:max_related]
    related = map(get_podcast, related)

    for p in related:
        podcast.related_podcasts.add(p)
示例#2
0
def update_related_podcasts(podcast, max_related=20):
    get_podcast = itemgetter(0)

    related = calc_similar_podcasts(podcast)[:max_related]
    related = map(get_podcast, related)

    for p in related:
        try:
            podcast.related_podcasts.add(p)
        except IntegrityError:
            logger.warn('Integrity error while adding related podcast',
                        exc_info=True)
示例#3
0
def update_related_podcasts(podcast_pk, max_related=20):
    get_podcast = itemgetter(0)

    podcast = Podcast.objects.get(pk=podcast_pk)

    related = calc_similar_podcasts(podcast)[:max_related]
    related = map(get_podcast, related)

    for p in related:
        try:
            podcast.related_podcasts.add(p)
        except IntegrityError:
            logger.warning("Integrity error while adding related podcast",
                           exc_info=True)
示例#4
0
    def handle(self, *args, **options):

        get_podcast = itemgetter(0)

        max_related = options.get('max')

        podcasts = all_podcasts()
        total = podcast_count()

        for (n, podcast) in enumerate(podcasts):

            l = calc_similar_podcasts(podcast)[:max_related]

            related = map(get_podcast, l)

            update_related_podcasts(podcast, related)

            progress(n+1, total)
示例#5
0
    def handle(self, *args, **options):

        get_podcast = itemgetter(0)

        max_related = options.get('max')

        podcasts = Podcast.all_podcasts()
        total = Podcast.view('podcasts/by_id', limit=0).total_rows

        for (n, podcast) in enumerate(podcasts):

            l = calc_similar_podcasts(podcast)[:max_related]

            related = map(get_podcast, l)

            @repeat_on_conflict(['podcast'])
            def _update(podcast, related):
                podcast.related_podcasts = related
                podcast.save()

            _update(podcast=podcast, related=related)

            progress(n+1, total)