Example #1
0
def updateSalary():
    c = MongoClient()

    for x in c.teachers.Collections.find():
        sal = salary.getSalary(x['first'],x['last'])
        c.teachers.Collections.update({"id":x['id']},{"$set":{"salary":sal[0],"salary_year":sal[1]}})
        print("%s %s - $%d"%(x['first'],x['last'],sal[0]))
def teachersToDatabase():
    c.teachers.Collections.remove()

    print("Adding in teachers to database...")
    
    teachers = getTeachers()
    for x in range(0,len(teachers)):
        t = teachers[x]
        t["id"] = x


        # add in teacher's salary
        gs = salary.getSalary(t["first"],t["last"])
        t["salary"] = int(gs[0])
        t["salary_year"] = int(gs[1])

        # array for multiple address results of teachers
        t["address"] = []
        addr = pFinder.pFind(t["first"],t["last"])

        if addr:
            for z in addr:
            # z["map"] = gmap()  --- placeholder for Google Maps function
                t["address"].append(z)

        t["rmt_overall"] = -1
        t["rmt_easiness"] = -1
        t["rmt_helpfulness"] = -1
        t["rmt_clarity"] = -1
        t["rmt_num_reviews"] = 0
            

        c.teachers.Collections.insert(teachers[x])

#        if t["salary"] == -1:
#            print("[%d] Error  %s %s"%(x,t["first"],t["last"]))
#        else:
        pr = "[%d]\t{{ %s %s }}\t"%(x,t["first"],t["last"])
        if t["salary"] == -1:
            pr += "Error "
        else:
            pr += "$%d"%(t["salary"])
        if(len(t["address"]) > 0):
            pr += "\t%s\t%s"%(t["address"][0]["phoneNum"],t["address"][0]["address"])
        else:
            pr += "No address found"
        pr += "\n"
        print(pr)



    do_ratemyteachers()
    distance.getTeachs()
    citibike.updateTeachers()
    do_zipcode()

    print("Done.")
Example #3
0
def updateSalary():
    c = MongoClient()

    for x in c.teachers.Collections.find():
        sal = salary.getSalary(x['first'], x['last'])
        c.teachers.Collections.update(
            {"id": x['id']},
            {"$set": {
                "salary": sal[0],
                "salary_year": sal[1]
            }})
        print("%s %s - $%d" % (x['first'], x['last'], sal[0]))