Example #1
0
def fetch_questions_and_answers():
    """Grab all questions/answers from Math.StackExchange and add to our db."""
    func = "/questions"
    params = {
        'pagesize': 100,
        'order': 'asc',
        'sort': 'creation',
        'filter': '!*IXk1kM1CRsCvNX-HctMr3GtJ1.gEYTy9JkKKBvy88x)lhGxe1N.aanvfrdZ)D'
    }
    process_each_page(func, params, \
            lambda x: process_api_questions(x, check_quality=False))
    set_last_updated() 
Example #2
0
def fetch_recent_questions():
    """Grab recent questions/answers from Math.StackExchange and update DB.

    "Recent" is defined as "since the last update".
    """
    ts = get_last_updated()
    if ts == dt.fromtimestamp(0):
        ts = dt.fromtimestamp(60*60*8)
    func = "/questions"
    params = {
            'pagesize': 100,
            'order': 'desc',
            'fromdate': int(mktime((ts - timedelta(hours=8)).timetuple())),
            'sort': 'activity',
            'filter': '!*IXk1kM1CRsCvNX-HctMr3GtJ1.gEYTy9JkKKBvy88x)lhGxe1N.aanvfrdZ)D'
    }
    process_each_page(func, params, process_api_questions)
    
    set_last_updated()