def write_odds_ends_batch(track_bits):
    from db_setup import insert_trips_database, insert_spans_database, insert_trips_temp_database
    locs, state, new_days = read_all_data_batch(track_bits)
    # if state == "not_first_time":
    #     locations = compute_locations(locs)
    #     file = get_semantic_file_with_learning(track_bits, locations)
    #     file.to_file("./location_semantics.txt")

    #check_gpx_changes(old_days, new_days)
    insert_trips_temp_database()
    insert_trips_database()
    insert_spans_database()
def write_odds_ends(track_bits, batch):
    from db_setup import insert_trips_database, insert_spans_database, insert_trips_temp_database
    locs, state, old_days, new_days = read_all_data(track_bits, batch)
    # if state == "not_first_time":
    #     locations = compute_locations(locs)
    #     file = get_semantic_file_with_learning(track_bits, locations)
    #     file.to_file("./location_semantics.txt")

    if not batch:
        check_gpx_changes(old_days, new_days)

    print "start database ", datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
    insert_trips_database()
    insert_trips_temp_database()
    insert_spans_database()
    print "end database ", datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]