Beispiel #1
0
def build_recommendations_by_topic():
    print('Deleting all predictions and rebuilding recommendations')
    Recommendation.objects.all().delete()
    for b in Business.objects.all():
        u = get_default_user()
        print('getting recommendationg for business ' + str(b) + ' for user ' + str(u))
        logger.debug('getting recommendationg for business ' + str(b) + ' for user ' + str(u))
        get_recommendation_by_topic(b,u)
Beispiel #2
0
def associate_business_with_types(bus,types):
    for tdescr in types:
        if tdescr == '':
            continue
        try:
            t = Type.objects.get(descr=tdescr) 
        except Type.MultipleObjectsReturned:
            logger.error("Multiple types returned")
            t = Type.objects.filter(descr=tdescr)[0] 
            pass
        except Type.DoesNotExist:
            logger.debug("Type " + str(tdescr) + " does not exist")
            if tdescr != '':
                t = Type(descr=tdescr,creator=get_default_user(),icon='none.png')
                t.save()
            #logger.error('Type does not exist")')
            pass
        associate_business_type(bus, t)