示例#1
0
文件: engine.py 项目: vinodyk/wikum
def get_posts(article):

    posts = article.comment_set
    if posts.count() == 0:

        if article.source.source_name == "The Atlantic":
            get_disqus_posts(article, None, None)
        elif article.source.source_name == "Reddit":
            get_reddit_posts(article, None, None)

        count_replies(article)

        posts = article.comment_set.filter(
            reply_to_disqus=None).order_by('-points')
    else:
        posts = posts.filter(reply_to_disqus=None).order_by('-points')

    if article.vectorizer == None:
        create_vectors(article)

        posts = article.comment_set.filter(reply_to_disqus=None)
        from website.views import recurse_viz
        recurse_viz(None, posts, False, article, False)

    return posts[0:10]
示例#2
0
文件: tasks.py 项目: amyxzhang/wikum
def import_article(url):
    source = get_source(url)
    if source:
        article = get_article(url, source, 0)
        if article:
            posts = article.comment_set
            total_count = 0
            
            if posts.count() == 0:
                if article.source.source_name == "The Atlantic":
                    get_disqus_posts(article, current_task, total_count)
                    
                elif article.source.source_name == "Reddit":
                    get_reddit_posts(article, current_task, total_count)
                    
                elif article.source.source_name == "Wikipedia Talk Page":
                    get_wiki_talk_posts(article, current_task, total_count)
                    
                count_replies(article)
        else:
            return 'FAILURE-ARTICLE'
    else:
        return 'FAILURE-SOURCE'
        
        
示例#3
0
def import_article(url):
    connection.close()
    
    source = get_source(url)
    if source:
        article = get_article(url, source, 0)
        if article:
            posts = article.comment_set
            total_count = 0
            
            if posts.count() == 0:
                if article.source.source_name == "The Atlantic":
                    get_disqus_posts(article, current_task, total_count)
                    
                elif article.source.source_name == "Reddit":
                    get_reddit_posts(article, current_task, total_count)
                    
                elif article.source.source_name == "Wikipedia Talk Page":
                    get_wiki_talk_posts(article, current_task, total_count)
                    
                count_replies(article)
        else:
            return 'FAILURE-ARTICLE'
    else:
        return 'FAILURE-SOURCE'
        
        
示例#4
0
文件: tasks.py 项目: vibster/wikum
def import_article(url, owner):
    source = get_source(url)

    if source:

        if owner == "None":
            user = None
        else:
            user = User.objects.get(username=owner)
        article = get_article(url, user, source, 0)
        if article:
            posts = article.comment_set
            total_count = 0

            if posts.count() == 0:
                if article.source.source_name == "The Atlantic":
                    get_disqus_posts(article, current_task, total_count)

                elif article.source.source_name == "Reddit":
                    get_reddit_posts(article, current_task, total_count, url)

                elif article.source.source_name == "Wikipedia Talk Page":
                    get_wiki_talk_posts(article, current_task, total_count)

                elif article.source.source_name == "Decide Proposal":
                    get_decide_proposal_posts(article, current_task,
                                              total_count)
                elif article.source.source_name == "JOIN Taiwan":
                    get_join_taiwan_posts(article, current_task, total_count)

                article.comment_num = article.comment_set.count()
                article.save()
                count_replies(article)

            set_link_article(article, article)
            article.save()
        else:
            return 'FAILURE-ARTICLE'
    else:
        return 'FAILURE-SOURCE'
示例#5
0
文件: engine.py 项目: amyxzhang/wikum
def get_posts(article):
    
    posts = article.comment_set
    if posts.count() == 0:
        
        if article.source.source_name == "The Atlantic":
            get_disqus_posts(article, None, None)
        elif article.source.source_name == "Reddit":
            get_reddit_posts(article, None, None)
                
        count_replies(article)
        
        posts = article.comment_set.filter(reply_to_disqus=None).order_by('-points')
    else:
        posts = posts.filter(reply_to_disqus=None).order_by('-points')
    
    if article.vectorizer == None:
        create_vectors(article)
        
        posts = article.comment_set.filter(reply_to_disqus=None)
        from website.views import recurse_viz
        recurse_viz(None, posts, False, article, False)
    
    return posts[0:10]