(filepath, toggles, increment_progress=None)
Generate a CSV file containing data for toggles. One row per enabled toggle item.
    If the toggle is not used a single row will still be included with the basic metadata
Generate a CSV file containing data for toggles. One row per enabled toggle item.
    If the toggle is not used a single row will still be included with the basic metadata
Generate a CSV file containing data for toggles . One row per enabled toggle item . If the toggle is not used a single row will still be included with the basic metadata
def _write_toggle_data(filepath, toggles, increment_progress=None):
    """Generate a CSV file containing data for toggles. One row per enabled toggle item.
    If the toggle is not used a single row will still be included with the basic metadata
    """
    fieldnames = [
        "env", "slug", "label", "tag", "type", "help", "description", "randomness",
        "enabled_for_new_domains_after", "enabled_for_new_users_after", "relevant_to_env",
        "user_count", "domain_count", "email_domain_count", "other_count", "error",
        "item", "item_namespace",
        # user columns
        "user_is_active", "user_is_dimagi", "user_is_mobile", "user_is_superuser", "user_last_login",
        # domain columns
        "domain_is_active", "domain_is_test", "domain_is_snapshot",
        "domain_has_dimagi_user", "domain_last_form_submission", "domain_has_submission_in_last_30_days",
        "domain_subscription_service_type", "domain_subscription_plan"
    ]
    with open(filepath, 'w', encoding='utf8') as file:
        writer = csv.DictWriter(file, fieldnames=fieldnames)
        writer.writeheader()

        for toggle in toggles:
            for row in _get_toggle_rows(toggle):
                writer.writerow(row)
                increment_progress and increment_progress()
def _write_toggle_data ( filepath , toggles , increment_progress = None ) : fieldnames = [ "env" , "slug" , "label" , "tag" , "type" , "help" , "description" , "randomness" , "enabled_for_new_domains_after" , "enabled_for_new_users_after" , "relevant_to_env" , "user_count" , "domain_count" , "email_domain_count" , "other_count" , "error" , "item" , "item_namespace" , # user columns "user_is_active" , "user_is_dimagi" , "user_is_mobile" , "user_is_superuser" , "user_last_login" , # domain columns "domain_is_active" , "domain_is_test" , "domain_is_snapshot" , "domain_has_dimagi_user" , "domain_last_form_submission" , "domain_has_submission_in_last_30_days" , "domain_subscription_service_type" , "domain_subscription_plan" ] with open ( filepath , 'w' , encoding = 'utf8' ) as file : writer = csv . DictWriter ( file , fieldnames = fieldnames ) writer . writeheader ( ) for toggle in toggles : for row in _get_toggle_rows ( toggle ) : writer . writerow ( row ) increment_progress and increment_progress ( )