Esempio n. 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
    }
Esempio n. 2
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
    }
from datetime import datetime
import smarttypes, sys, string
from smarttypes.config import *
from smarttypes.model.twitter_credentials import TwitterCredentials
from smarttypes.model.twitter_user import TwitterUser
from smarttypes.model.twitter_reduction import TwitterReduction

from smarttypes.utils.postgres_handle import PostgresHandle
postgres_handle = PostgresHandle(smarttypes.connection_string)

if __name__ == "__main__":

    user_count_list = TwitterReduction.get_user_reduction_counts(
        postgres_handle)
    for user, count in user_count_list:
        if count == 1:
            creds = TwitterCredentials.get_by_twitter_id(
                user.id, postgres_handle)
            creds.maybe_send_initial_map_email()
from datetime import datetime
import smarttypes, sys, string
from smarttypes.config import *
from smarttypes.model.twitter_credentials import TwitterCredentials
from smarttypes.model.twitter_user import TwitterUser
from smarttypes.model.twitter_reduction import TwitterReduction

from smarttypes.utils.postgres_handle import PostgresHandle

postgres_handle = PostgresHandle(smarttypes.connection_string)


if __name__ == "__main__":

    user_count_list = TwitterReduction.get_user_reduction_counts(postgres_handle)
    for user, count in user_count_list:
        if count == 1:
            creds = TwitterCredentials.get_by_twitter_id(user.id, postgres_handle)
            creds.maybe_send_initial_map_email()