def previous_diff(data_point): prev = DataPoint.get_previous_by_created_at(data_point, user=data_point.user) lost, gained = diff_data_points(prev, data_point) return { 'data_point': data_point, 'prev': prev, 'lost': lost, 'gained': gained }
def create_data_point(user): friends = friends_lookup(user) if friends: data_point = DataPoint(user=user) data_point.save() make_friend_list(data_point, friends)