Beispiel #1
0
def index(req, session, postgres_handle):
    #if it's not a valid request keep reduction_id None
    #don't do work for bots that don't know what they're
    #looking for
    reduction = None
    user_reduction_counts = TwitterReduction.get_user_reduction_counts(
        postgres_handle)
    random.shuffle(user_reduction_counts)

    if req.path.split('/') > 1 and req.path.split(
            '/')[1]:  # path looks like '/something'
        root_user = TwitterUser.by_screen_name(
            req.path.split('/')[1], postgres_handle)
        if root_user:
            reduction = TwitterReduction.get_latest_reduction(
                root_user.id, postgres_handle)
        if not reduction and is_int(req.path.split('/')[1]):
            reduction = TwitterReduction.get_by_id(
                req.path.split('/')[1], postgres_handle)
    else:
        reduction = TwitterReduction.get_latest_reduction(
            user_reduction_counts[0][0].id, postgres_handle)

    return {
        'reduction_id':
        reduction.id
        if reduction and reduction.tiles_are_written_to_disk else None,
        'reduction':
        reduction
        if reduction and reduction.tiles_are_written_to_disk else None,
        'user_reduction_counts':
        user_reduction_counts
    }
Beispiel #2
0
def community_features(req, session, postgres_handle):
    reduction = None
    if req.path.split('/') > 3 and req.path.split('/')[3]:  # path looks like '/social_map/community_features/something'
        root_user = TwitterUser.by_screen_name(req.path.split('/')[3], postgres_handle)
        if root_user:
            reduction = TwitterReduction.get_latest_reduction(root_user.id, postgres_handle)
        if not reduction and is_int(req.path.split('/')[3]):
            reduction = TwitterReduction.get_by_id(req.path.split('/')[3], postgres_handle)
    return {
        'content_type': 'application/json',
        'json':reduction.get_geojson_community_features() if reduction else [],
    }
Beispiel #3
0
def index(req, session, postgres_handle):
    #if it's not a valid request keep reduction_id None
    #don't do work for bots that don't know what they're 
    #looking for
    reduction = None
    user_reduction_counts = TwitterReduction.get_user_reduction_counts(postgres_handle)
    random.shuffle(user_reduction_counts)

    if req.path.split('/') > 1 and req.path.split('/')[1]:  # path looks like '/something'
        root_user = TwitterUser.by_screen_name(req.path.split('/')[1], postgres_handle)
        if root_user:
            reduction = TwitterReduction.get_latest_reduction(root_user.id, postgres_handle)
        if not reduction and is_int(req.path.split('/')[1]):
            reduction = TwitterReduction.get_by_id(req.path.split('/')[1], postgres_handle)
    else:
        reduction = TwitterReduction.get_latest_reduction(user_reduction_counts[0][0].id, postgres_handle)

    return {
        'reduction_id': reduction.id if reduction and reduction.tiles_are_written_to_disk else None,
        'reduction': reduction if reduction and reduction.tiles_are_written_to_disk else None,
        'user_reduction_counts': user_reduction_counts
    }