예제 #1
0
    def handle(self, *args, **options):
        if options['deleteall']:
            MImage.drop()
            return

        if options['daemonize']:
            daemonize()

        settings.LOG_TO_STREAM = True

        # Added by Xinyan Lu: domain based feed refresh
        if options['domain']:
            feeds = Feed.objects.filter(
                feed_address__contains=options['domain'])
        elif options['id']:
            feeds = Feed.objects.filter(id=options['id'])
        else:
            feeds = Feed.objects.filter(num_subscribers__gte=1)

        # feeds = feeds.order_by('?')

        num_feeds = len(feeds)
        print 'num feeds', num_feeds
        for feed in feeds:
            UpdateFeedImages.apply_async(args=(feed.pk, ),
                                         queue='update_feed_images')
        print 'dispatch done'
예제 #2
0
    def handle(self, *args, **options):
        if options['deleteall']:
            MImage.drop()
            return

        if options['daemonize']:
            daemonize()
        
        settings.LOG_TO_STREAM = True        
            
        # Added by Xinyan Lu: domain based feed refresh
        if options['domain']:
            feeds = Feed.objects.filter(feed_address__contains=options['domain'])
        elif options['id']:
            feeds = Feed.objects.filter(id=options['id'])
        else:
            feeds = Feed.objects.filter(num_subscribers__gte=1)
        
        # feeds = feeds.order_by('?')

        num_feeds = len(feeds)
        print 'num feeds',num_feeds
        for feed in feeds:
            UpdateFeedImages.apply_async(args=(feed.pk,), queue='update_feed_images')
        print 'dispatch done'
예제 #3
0
def imagesearch(request, page_num):
    if page_num == '':
        page_num = '1'
    page_num = int(page_num)
    num_per_page = 15

    q = request.GET.get('q', None)
    if q:
        image_server = settings.FDFS_HTTP_SERVER
        index_stories = SearchStory.query(q)[:500]
        response_images = []
        for index_story in index_stories:
            story = MStory.objects(id=index_story['db_id']).first()
            if story and story.image_ids:
                for image_id in story.image_ids:
                    if len(image_id) > 20:
                        # print image_id
                        image = MImage.objects(id=image_id).first()
                        imagedict = dict(
                            image_url=image_server + image.image_remote_id,
                            story_url=story.story_guid,
                            story_title=story.story_title,
                        )
                        response_images.append(imagedict)
                        if len(response_images) >= 50:
                            return render(request, 'imagesearch.html',
                                          locals())
    return render(request, 'imagesearch.html', locals())
예제 #4
0
def imagesearch(request,page_num):
	if page_num == '':
		page_num = '1'
	page_num = int(page_num)
	num_per_page = 15

	q = request.GET.get('q',None)
	if q:
		image_server = settings.FDFS_HTTP_SERVER
		index_stories = SearchStory.query(q)[:500]
		response_images = []
		for index_story in index_stories:
			story = MStory.objects(id=index_story['db_id']).first()	
			if story and story.image_ids:
				for image_id in story.image_ids:
					if len(image_id) > 20:
						# print image_id
						image = MImage.objects(id=image_id).first()
						imagedict = dict(
							image_url=image_server+image.image_remote_id,
							story_url=story.story_guid,
							story_title = story.story_title,
							)
						response_images.append(imagedict)
						if len(response_images)>=50:
							return render(request,'imagesearch.html',locals())
	return render(request,'imagesearch.html',locals())