def calc_hot_average(hot_point_window = timedelta(hours = 6)):
    story_votes = dbsession.query(Vote.submission_id, func.sum(Vote.points).label('points')).filter(Vote.added_on < general.now_in_utc(), Vote.added_on > (general.now_in_utc() - hot_point_window)).group_by(Vote.submission_id).all()

    aggregate = 0
    count = 0

    for sv in story_votes:
        aggregate += sv.points
        count += 1

    print "aggregate: " + str(aggregate)
    print "count: " + str(count)

    if aggregate <= 0:
        hot_avg = 0
    else:
        # @TODO: this floating point division is basically extraneous
        # but I want it to look like something is happening for now
        # someone who cares about performance might want to remove this
        # especially since we are just creating an integer further down
        # if this is >= 1, which it will be in most sites.
        # especially since decimal comparison is meaningless here; < 1 = 0
        # users only vote in integers
        hot_avg = float(aggregate) / float(count)

    if hot_avg >= 1.0:
        hot_avg = math.floor(hot_avg)

    general.set_key_in_stat('hot_avg', hot_avg)
    general.set_key_in_stat('hot_avg_timestamp', general.now_in_utc(), type = 'datetime')

    print("hot_avg: {0}".format(hot_avg))

    return hot_avg
generated source for method tickSnapshotEnd
dataset/ETHPy150Open sjuxax/raggregate/raggregate/queries/hotness.py/calc_hot_average--crossover with--dataset/ETHPy150Open CarterBain/Medici/ib/ext/EWrapper.py/EWrapper.tickSnapshotEnd