Ejemplo n.º 1
0
def update_hours(days):
    for date in days.iterkeys():
        # New Keyholders get boosted to the median
        for key in tif.Keyholder.keyholders.itervalues():
            if key.start_date == date:
                key.credits = tif.Keyholder.keyholders['MED'].credits
        # And then we add the work on that day
        for record in days[date]:
            record['key'].add_work(
                tif.Credit(date, record['minutes'], record['flags']))
        old = tif.last_median()  # in minutes
        new = tif.compute_median()
        the_median = tif.from_initials(tif.MEDIAN)
        while ((new - old) >= tif.MEDIAN_INCREMENT):
            the_median.add_work(tif.Credit(date, tif.MEDIAN_INCREMENT))
            old = tif.last_median()
            for key in tif.Keyholder.keyholders.itervalues():
                if key.active_on(date) and key.gets_vacation(date):
                    key.add_work(tif.Credit(date, tif.MEDIAN_INCREMENT, "a"))
                    print "%s gets %d minutes of vacation credit on %r." % (
                        key.initials, tif.MEDIAN_INCREMENT.seconds / 60, date)
        old = tif.last_median()
        while (old >= tif.ROTATION_MAX):
            the_median.add_lameness(
                tif.Credit(date, tif.ROTATION_MAX - tif.ROTATION_MIN))
            minmed = tif.min_median_date()
            for key in tif.active_keys(date):
                key.add_lameness(
                    tif.Credit(date, tif.ROTATION_MAX - tif.ROTATION_MIN))
                key.expire_lameness(minmed)
            old = tif.last_median()
            print "Chart rotates, median moves back to %s on %s." % (
                tif.to_hours(tif.last_median()), date)
Ejemplo n.º 2
0
def update_hours(days):
    for date in days.iterkeys():
        # New Keyholders get boosted to the median
        for key in tif.Keyholder.keyholders.itervalues(): 
            if key.start_date == date:
                key.credits = tif.Keyholder.keyholders['MED'].credits
        # And then we add the work on that day
        for record in days[date]:
            record['key'].add_work(tif.Credit(date,
                                              record['minutes'],
                                              record['flags']))
        old = tif.last_median() # in minutes
        new = tif.compute_median()
        the_median = tif.from_initials(tif.MEDIAN)
        while ((new - old) >= tif.MEDIAN_INCREMENT):
            the_median.add_work(tif.Credit(date,
                                           tif.MEDIAN_INCREMENT))
            old = tif.last_median()
            for key in tif.Keyholder.keyholders.itervalues():
                if key.active_on(date) and key.gets_vacation(date):
                    key.add_work(tif.Credit(date,
                                            tif.MEDIAN_INCREMENT,
                                            "a"))
                    print "%s gets %d minutes of vacation credit on %r." % (key.initials, tif.MEDIAN_INCREMENT.seconds/60, date)
        old = tif.last_median()
        while (old >= tif.ROTATION_MAX):
            the_median.add_lameness(tif.Credit(date,
                                               tif.ROTATION_MAX - tif.ROTATION_MIN))
            minmed = tif.min_median_date()
            for key in tif.active_keys(date):
                key.add_lameness(tif.Credit(date,
                                            tif.ROTATION_MAX - tif.ROTATION_MIN))
                key.expire_lameness(minmed)
            old = tif.last_median()
            print "Chart rotates, median moves back to %s on %s." % (tif.to_hours(tif.last_median()), date)
Ejemplo n.º 3
0
def summary():
    load()
    active_keyholders = active_keys(date.today())  # was max
    active_keyholders.sort(
        lambda a, b: minutes(b.current_balance() - a.current_balance()))
    last = last_median()
    print "%10s%12s%14s (=%s)\n" % ("Keyholder", "Position", "vs. Median",
                                    (hours_minutes(last)))
    for key in active_keyholders:
        if key.initials == MEDIAN: continue
        print "%10s%12s%14s" % (key.initials,
                                hours_minutes(key.current_balance()),
                                hours_minutes(key.current_balance() - last))
Ejemplo n.º 4
0
def summary():
    load()
    active_keyholders = active_keys(date.today()) # was max
    active_keyholders.sort(
        lambda a,b: minutes(b.current_balance() - a.current_balance()))
    last = last_median()
    print "%10s%12s%14s (=%s)\n" % ("Keyholder","Position","vs. Median",
                                    (hours_minutes(last)))
    for key in active_keyholders:
        if key.initials==MEDIAN: continue
        print "%10s%12s%14s" % (key.initials,
                                hours_minutes(key.current_balance()),
                                hours_minutes(key.current_balance() - last))