Exemplo n.º 1
0
def print_session(doc):
    print(he.indent())
    #print("ID:", doc["_id"])
    day = doc["day"]

    assert type(day) == int

    day = conv.convert_int_todate(day)

    print("Date:" + day)
    print("Type:", doc["type"])

    if doc["type"] != "off":

        if doc["type"] == "run":
            run = doc["run"]
            print("Distance:", run[0], "km")
            print("Durationen: " + conv.convert_float_totime(run[1]))
            print("average Pace: " + conv.convert_float_totime(run[2]))

        elif doc["type"] == "hike":
            hike = doc["hike"]
            print("Distance:", hike[0], "km")
            print("Height meter:", hike[1], "m")
            print("Duration: " + conv.convert_float_totime(hike[2]))

        elif doc["type"] == "cardio":
            run = doc["run"]
            distance = run[1] / 60 * run[0]
            print("Run: " + conv.convert_float_totime(run[1]) + " at", run[0],
                  "(" + str(distance) + ")")

            circuit = doc["circuit"]
            print("Circuit:", circuit[0], "Rounds")
            for exercise in circuit[1:]:
                reps = str(exercise[1])
                weight = str(exercise[2])
                print(exercise[0] + ": " + reps + "x" + weight)

        else:
            n = doc["amount of exercises"]
            print("Amount of exercises:", n)
            print("List of exercises:", end=" ")
            ex = doc["exercise list"]
            for i in range(n - 1):
                print(ex[i], ",", end=" ")
            print(ex[n - 1])
            for i in range(n):
                print_exercise(doc["exercise" + str(i + 1)])

    if len(doc["comments"]) > 3: print("Comments: " + doc["comments"])
    print(he.indent())
Exemplo n.º 2
0
def see_cache():
    print(he.indent())
    global CACHE_DIR
    directory = CACHE_DIR
    os.chdir(directory)
    
    print("Dates with cached session:")
    for file_ in glob.glob("*.txt"):
        day = file_.replace(".txt", "")
        day = day.replace("(1)", "")
        
        
        day = int(day)
        
        date = conv.convert_int_todate(day)
        
        print(date)
Exemplo n.º 3
0
def group_summary(db, group):

    headers = ["Date"]
    line = ["-"]
    for ex in group:
        headers.append(ex)
        line.append("-")
    line.append("0")
    headers.append("Total Reps")
    content = []
    reps_all = []
    for session in db["AllSessions"].find().sort("day"):
        type_ = session["type"]
        if type_ in filter.STR_TYPES:
            exlist = session["exercise list"]
            if check.stringlist_in_stringlist(group, exlist):
                line[0] = conv.convert_int_todate(session["day"])
                sets = 0
                for ex in group:
                    if ex in exlist:
                        exercise, day = get_exercise(session, ex)
                        index = group.index(ex) + 1
                        if len(exercise) == 4:
                            line[index] = str(exercise[1]) + "x" + str(
                                exercise[2]) + "x" + str(exercise[3])
                            sets += exercise[1] * exercise[2]
                        else:
                            line[index] = " "
                            for rep, weight in zip(exercise[1], exercise[2]):
                                line[index] += str(rep) + "x" + str(
                                    weight) + ", "
                            line[index] = line[index][:-2]
                            sets += sum(exercise[1])
                reps_all.append(sets)
                line[len(group) + 1] = str(sets)
                content.append(line)
                line = reset(line)

    index_reps = indexes_max(reps_all)
    content = color_content(content=content, index_reps=index_reps, group=True)

    print(tabulate(content, headers))
Exemplo n.º 4
0
def summary_off(db):
   
    off_days = filter.filter_type(db, "off")
    strength_days = filter.filter_filtered(db["AllSessions"].find(), "strength")
    run_days = filter.filter_type(db, "run")
    
    print(he.indent())
    
    print("Number off days:", len(off_days))
    print("Number Stength days:", len(strength_days))
    print("Number Runs:", len(run_days))
    
    today = he.today()
    print("Total days:", he.get_day_in_year(today))
    
    last_off = off_days[-1]
    last_off_day = conv.convert_int_todate(last_off["day"])
    print("Last off day:", last_off_day)
    
    days_since_off = he.get_day_in_year(today) - last_off["day"]
    print("Days since off:", days_since_off)
    
    print(he.indent())
    
    content = []
    year = he.year_now()
    for month in range(1,he.month_now()+1):
        monthly_days = he.monthly_days(int(year))
        days = [sum(monthly_days[:month-1])+1,sum(monthly_days[:month])]
        
        counter_month_off = 0
        for session in off_days:
            if session["day"] <= days[1] and session["day"] >= days[0]:
                counter_month_off += 1
        
        counter_month_strength = 0
        for session in strength_days:
            if session["day"] <= days[1] and session["day"] >= days[0]:
                counter_month_strength += 1
                
        counter_month_run = 0
        for session in run_days:
            if session["day"] <= days[1] and session["day"] >= days[0]:
                counter_month_run += 1
            
        
        content.append([conv.convert_to_month(month), str(counter_month_strength), 
                        str(counter_month_run),str(counter_month_off)])
        #print(conv.convert_to_month(month)+ ":" ,counter_month)
    
    header = ["Month", "Strength days", "Runs", "Off days"]
    out = tabulate(content, header)
    print(out)
    
    missing = get_missing(db)
    if missing != []:
        missing_dates = []
        for day in missing:
            missing_dates.append(conv.convert_int_todate(day))
        
        print("These dates are missing:", missing_dates)   
        dec = input("Fill with off days [y/n]: ")
    
        if dec == "y":
            fill_off(db, missing)
Exemplo n.º 5
0
def exercise_summary(db, exercise):
    ex_list, days = filter.filter_exercise(db, exercise)
    global BW_EXERCISES

    for ex in BW_EXERCISES:
        if ex in exercise:
            bw = True
            headers = ["Date", "Workload", "Total Reps"]
            break
        else:
            bw = False
            headers = ["Date", "Workload", "Volume", "Max Weight", "1RM"]

    content = []
    total_reps = []
    volume = []
    onerm = []

    for ex, day in zip(ex_list, days):
        data = [conv.convert_int_todate(day)]

        assert len(ex) == 4 or len(ex) == 3

        if len(ex) == 4:
            setsreps = str(ex[1]) + "x" + str(ex[2]) + "x" + str(ex[3])
            total_reps.append(ex[1] * ex[2])
            if "BW" == ex[3]: bw_ = True
            else: bw_ = False

        else:
            setsreps = " "
            for rep, weight in zip(ex[1], ex[2]):
                setsreps += str(rep) + "x" + str(weight) + ", "
            setsreps = setsreps[:-2]
            total_reps.append(sum(ex[1]))
            if "BW" in ex[2]: bw_ = True
            else: bw_ = False

        data.append(setsreps)

        if not bw:
            if not bw_:
                volume.append(calc.vol(ex))
                data.append(str(volume[-1]))

                reps_max = calc.reps_max_weight(ex)
                weight_max = calc.max_w(ex)
                data.append(str(reps_max) + "x" + str(weight_max))
            else:
                data.append("-")
                data.append("-")
                volume.append(0)
            try:
                onerm.append(calc.estimate_onerm(reps_max, weight_max))
                data.append(str(onerm[-1]))
            except:
                data.append("-")
                onerm.append(0)
        else:
            data.append(str(total_reps[-1]))

        content.append(data)

    if bw:
        index_reps = indexes_max(total_reps)
        content = color_content(content=content, index_reps=index_reps)
    else:
        index_volume = indexes_max(volume)
        index_onerm = indexes_max(onerm)
        content = color_content(content=content,
                                index_volume=index_volume,
                                index_onerm=index_onerm)

    print(tabulate(content, headers))