コード例 #1
0
    def __init__(self, desc_len, summ_len):
        self.desc_length = desc_len
        self.summ_length = summ_len

        self.t_processor = Text_Process(self.desc_length, self.summ_length)
        self.wk_mgt = WikipediaHelper(self.desc_length, self.summ_length)
        self.t_creator = TopicManager()
        self.tl_creator = TopicLinkManager()
コード例 #2
0
from datetime import datetime, timedelta
from diggly.util.diggly_threads import FuncThread
from django.db.models import Max, Q
from diggly.models import Topic, FeaturedTopics, TopicRedirect
from diggly.util.wikipediaAPI.wiki_api import WikipediaHelper
from bs4 import BeautifulSoup
import requests

#constants; to be moved to another file
TRENDING_TOPICS_URL = "http://wikipedia.trending.eu/en/__[404]24/"
TRENDING_TOPICS_BACKUP_URL = "http://tools.wmflabs.org/wikitrends/english-most-visited-today.html"

GET_PAGE_ID_URL = "http://rack36.cs.drexel.edu/getpageid/?q="

wiki_help = WikipediaHelper()


def update_featured_object(topic):
    #Get featured topics instance
    now = datetime.now()
    earlier_recent = timedelta(
        minutes=15)  #within last 15 mins (applies to recent topics)
    earlier_trending = timedelta(
        days=1)  #within last 1 day (applies to trending topics)

    topic.visit_counter += 1
    topic.save()

    try:
        featured_topics = FeaturedTopics.objects.all()[0]
        recent_topics = featured_topics.recent_topics