Ejemplo n.º 1
0
    def GET(self, domain):
        trimmed_domain = domain.replace(".com", "")
        r_server = redis.StrictRedis(connection_pool=CONNECTION_POOL)
        intended_domain_id = r_server.hget(r_utils.get_typo_key(trimmed_domain), 'intended')
        if intended_domain_id is None:
            return ''

        intended_domain = r_server.hget(r_utils.get_domain_key(intended_domain_id), 'url')
        return URL_CORRECTION_FORMAT.format(intended_domain)
Ejemplo n.º 2
0
def identify_conflict(r_server, domain, typo):
    typo_key = r_utils.get_typo_key(typo)
    if r_server.exists(typo_key):
        domain_id = r_server.hget(typo_key, 'intended')
        intended_domain = r_server.hget(r_utils.get_domain_key(domain_id), 'url')
        print 'conflict for ' + domain + ' on ' + typo + ' (' + intended_domain + ')'
Ejemplo n.º 3
0
def add_domain(r_server, domain):
    domain_id = r_server.incr(r_utils.DOMAIN_ID_KEY)
    r_server.hset(r_utils.get_domain_key(domain_id), 'url', domain)
    r_server.hset(r_utils.DOMAIN_NAME_KEY_FORMAT.format(domain), 'id', domain_id)
    return domain_id