def can_add_fp_to_track(conn, track_id, fingerprint, length):
    cond = schema.fingerprint.c.track_id == track_id
    query = sql.select([
        sql.func.acoustid_compare2(schema.fingerprint.c.fingerprint, fingerprint, const.TRACK_MAX_OFFSET),
        schema.fingerprint.c.length,
    ], cond, from_obj=schema.fingerprint)
    for fp_score, fp_length in conn.execute(query):
        if fp_score < const.TRACK_GROUP_MERGE_THRESHOLD:
            return False
        if abs(fp_length - length) > const.FINGERPRINT_MAX_LENGTH_DIFF:
            return False
    return True
dataset/ETHPy150Open lalinsky/acoustid-server/acoustid/data/track.py/can_add_fp_to_track/original