Exemple #1
0
def generate_all_rankings(whatever=None,skip_if_set=True,range=(0,0)):
    cities = City.objects.all()[range[0]:range[1]]
    resp = ""
    for c in cities:
        wname = None
        if c.wikiname is None:
            name = _wikipedia_article(c.name)
            if (name is not None): wname = name['wikiname']
        else:
            if(skip_if_set is True):
                wname = None
            else:
                wname = c.wikiname

        if wname is not None:
            r1 = (wikipedia_ranking(wname))
            r2 = (panoramio_ranking(c.name))
            r3 = decimal.Decimal("0.0")            
                
            c.wikiname = wname
            c.setRating(r1['content'],r2,r3)
            c.save()
            
                
            resp += "%s (%s) [%d,%d]\n" % (c.name,wname,r1['content'],r2)
    
    resp += "Done\n"
    
    return resp
def rank_city(city,save=True):
    # here we are, the rankings
    if(city.wikiname is not None):
        r1 = (wikipedia_ranking(city.wikiname))
        r1 = r1['content']
    else:
        r1 = 0.0
        
    r2 = (panoramio_ranking(city.id))
    r3 = (yahootravel_ranking(city.id))

    city.setRating(r1,r2,r3)
    if(save): city.save()
Exemple #3
0
def generate_requested_rankings(whatever=None,skip_if_set=True,range=(0,0)):
    cities = City.objects.filter(recompute=True)[range[0]:range[1]]
    resp = ""
    for c in cities:
                
        r1 = (wikipedia_ranking(c.wikiname))
        r2 = (panoramio_ranking(c.id))
        r3 = (yahootravel_ranking(c.id))            
                
        c.setRating(r1['content'],r2,r3)        
        #c.rating_factor_2 = r2   
        c.save()

        resp += "%s (%s) [%d,%d,%d]\n" % (c.name,c.wikiname,r1['content'],r2,r3)
    
    resp += "Done\n"
    
    return resp