in mozilla_schema_generator/glean_ping.py [0:0]
def _is_field_included(ping_data, field_name, consider_all_history=True) -> bool:
"""Return false if the field exists and is false.
If `consider_all_history` is False, then only check the latest value in the ping history.
Otherwise, if the field is not found or true in one or more history entries,
true is returned.
"""
# Default to true if not specified.
if "history" not in ping_data or len(ping_data["history"]) == 0:
return True
# Check if at some point in the past the field has already been deployed.
# And if the caller of this method wants to consider this history of the field.
# Keep them in the schema, even if the field has changed as
# removing fields is currently not supported.
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1898105
# and https://bugzilla.mozilla.org/show_bug.cgi?id=1898105#c10
ping_history: list
if consider_all_history:
ping_history = ping_data["history"]
else:
ping_history = [ping_data["history"][-1]]
for history in ping_history:
if field_name not in history or history[field_name]:
return True
# The ping was created with include_info_sections = False. The fields can be excluded.
return False