<commit_before>[
  <%- @pipeline_groups.each_with_index do |pipeline_group, group_index| -%>
  <%- is_last_group = group_index == @pipeline_groups.count - 1 -%>
  {
    "name": <%== pipeline_group.getName().to_json %>,

    <%-# ====== ====== EVERY PIPELINE IN THIS GROUP ====== ====== -%>
    "pipelines": [
      <%- pipeline_group.getPipelineModels().each_with_index do |pipeline_model, pipeline_index| -%>
      <%- is_last_pipeline = pipeline_index == pipeline_group.getPipelineModels().count - 1 -%>
      {
        "name": <%== pipeline_model.getName().to_json %>,

        <%-# ====== ====== EVERY CURRENTLY RUNNING INSTANCE OF THIS PIPELINE ====== ====== -%>
        "instances": [
          <%- pipeline_model.getActivePipelineInstances().each_with_index do |active_instance, instance_index| -%>
          <%- is_last_instance = instance_index == pipeline_model.getActivePipelineInstances().count - 1 -%>
          <%- if active_instance.hasHistoricalData() -%>
          {
            "has_history": "true",
            "label": <%== active_instance.getLabel().to_json() %>,
            "scheduled_time": <%== active_instance.getScheduledDate().getTime().to_json() %>,
            "history_path": <%== url_for_pipeline(active_instance.getName()).to_json() %>,
            "settings_path": <%== pipeline_edit_path(:pipeline_name => active_instance.getName(), :current_tab => "general").to_json() %>,
            "vsm_path": <%== url_for_pipeline_value_stream_map(active_instance, :only_path => true).to_json() %>,
            "compare_path": <%== compare_pipelines_path(:pipeline_name => active_instance.getName(), :from_counter => active_instance.getCounter() - 1, :to_counter => active_instance.getCounter()).to_json() %>,
            "build_cause_path": <%== build_cause_path(:pipeline_name => active_instance.getName(), :pipeline_counter => active_instance.getCounter()).to_json() %>,
            <%-# TODO: As in pipelines_helper.rb#trigger_message, check the pim type against PreparingToScheduleInstance? -%>
            "triggered_by": <%== active_instance.getApprovedBy().to_json() %>,
            <%- latest_stage = active_instance.latestStage() -%>
            "latest_stage_name": <%== latest_stage.getName().to_json() %>,
            "latest_stage_state": <%== latest_stage.getState().to_s.to_json() %>,

            <%-# ====== ====== EVERY STAGE IN THIS PIPELINE INSTANCE ====== ====== -%>
            "stages": [
              <%- active_instance.getStageHistory().each_with_index do |stage, stage_index| -%>
              <%- is_last_stage = stage_index == active_instance.getStageHistory().count - 1 -%>
              {
                "name": <%== stage.getName().to_json() %>,
                "status": "<%== stage.getState() %>",
                "details_path": <%== stage_detail_tab_path(:pipeline_name => active_instance.getName(), :pipeline_counter => active_instance.getCounter(),
                :stage_name => stage.getName(), :stage_counter => stage.getCounter(), :only_path => true).to_json() %>
              }<%== is_last_stage ? "" : "," %>
              <%- end -%>
            ]
          }<%== is_last_instance ? "" : "," %>
          <%- else -%>
          {
            "has_history": "false"
          }<%== is_last_instance ? "" : "," %>
          <%- end -%>
          <%- end -%>
        ],


        <%-# ====== ====== PREVIOUS RUN INFO (TO SHOW WHETHER THIS STAGE FAILED BEFORE ...) ====== ====== -%>
        <%- if pipeline_model.getLatestPipelineInstance().isAnyStageActive() -%>
        <%- active_stage = pipeline_model.getLatestPipelineInstance().activeStage() -%>
        <%- if active_stage.hasPreviousStage() -%>
        "previous_instance": { <%# TODO: Handle previously blurb. %>
          "result": <%== active_stage.getPreviousStage().getResult().to_s.to_json() %>,
          "details_path": <%== stage_detail_path_for_identifier(active_stage.getPreviousStage().getIdentifier()).to_s.to_json() %>,
          "pipeline_label": <%== active_stage.getPreviousStage().getIdentifier().getPipelineLabel().to_json() %>
        },
        <%- end -%>
        <%- end -%>


        <%-# ====== ====== OPERATIONS (TRIGGER, PAUSE ...) ====== ====== -%>
        <%- is_paused = pipeline_model.getPausedInfo().isPaused() -%>
        "available_operations": [
        <%- if pipeline_model.canOperate() -%>
          {
            "operation": "trigger",
            "operation_path": <%== api_pipeline_action_path(:pipeline_name => pipeline_model.getName(), :action => "schedule").to_json() %>
          },
          {
            "operation": "trigger_with_options",
            "operation_path": <%== pipeline_show_with_option_path.to_json() %>
          },
          {
            "operation": <%== (is_paused ? "unpause" : "pause").to_json() %>,
            "operation_path": <%== (is_paused ? unpause_pipeline_path(pipeline_model.getName()) : pause_pipeline_path(pipeline_model.getName())).to_json() %>
          }
        <%- end -%>
        ],


        <%-# ====== ====== PAUSE INFORMATION (MESSAGE, PAUSED_BY ...) ====== ====== -%>
        "pause_info": {
          "is_paused": <%== is_paused.to_json() + (is_paused ? "," : "") %>
          <%- if is_paused -%>
          "paused_by": <%== pipeline_model.getPausedInfo().getPauseBy().to_json() %>,
          "message": <%== pipeline_model.getPausedInfo().getPauseCause().to_json() %>
          <%- end -%>
        }
      }<%== is_last_pipeline ? "" : "," %>
      <%- end -%>
    ]
  }<%== is_last_group ? "" : "," %>
  <%- end -%>
]<commit_msg>#371 - Change: .to_json() => .to_json<commit_after>[
  <%- @pipeline_groups.each_with_index do |pipeline_group, group_index| -%>
  <%- is_last_group = group_index == @pipeline_groups.count - 1 -%>
  {
    "name": <%== pipeline_group.getName().to_json %>,

    <%-# ====== ====== EVERY PIPELINE IN THIS GROUP ====== ====== -%>
    "pipelines": [
      <%- pipeline_group.getPipelineModels().each_with_index do |pipeline_model, pipeline_index| -%>
      <%- is_last_pipeline = pipeline_index == pipeline_group.getPipelineModels().count - 1 -%>
      {
        "name": <%== pipeline_model.getName().to_json %>,

        <%-# ====== ====== EVERY CURRENTLY RUNNING INSTANCE OF THIS PIPELINE ====== ====== -%>
        "instances": [
          <%- pipeline_model.getActivePipelineInstances().each_with_index do |active_instance, instance_index| -%>
          <%- is_last_instance = instance_index == pipeline_model.getActivePipelineInstances().count - 1 -%>
          <%- if active_instance.hasHistoricalData() -%>
          {
            "has_history": "true",
            "label": <%== active_instance.getLabel().to_json %>,
            "scheduled_time": <%== active_instance.getScheduledDate().getTime().to_json %>,
            "history_path": <%== url_for_pipeline(active_instance.getName()).to_json %>,
            "settings_path": <%== pipeline_edit_path(:pipeline_name => active_instance.getName(), :current_tab => "general").to_json %>,
            "vsm_path": <%== url_for_pipeline_value_stream_map(active_instance, :only_path => true).to_json %>,
            "compare_path": <%== compare_pipelines_path(:pipeline_name => active_instance.getName(), :from_counter => active_instance.getCounter() - 1, :to_counter => active_instance.getCounter()).to_json %>,
            "build_cause_path": <%== build_cause_path(:pipeline_name => active_instance.getName(), :pipeline_counter => active_instance.getCounter()).to_json %>,
            <%-# TODO: As in pipelines_helper.rb#trigger_message, check the pim type against PreparingToScheduleInstance? -%>
            "triggered_by": <%== active_instance.getApprovedBy().to_json %>,
            <%- latest_stage = active_instance.latestStage() -%>
            "latest_stage_name": <%== latest_stage.getName().to_json %>,
            "latest_stage_state": <%== latest_stage.getState().to_s.to_json %>,

            <%-# ====== ====== EVERY STAGE IN THIS PIPELINE INSTANCE ====== ====== -%>
            "stages": [
              <%- active_instance.getStageHistory().each_with_index do |stage, stage_index| -%>
              <%- is_last_stage = stage_index == active_instance.getStageHistory().count - 1 -%>
              {
                "name": <%== stage.getName().to_json %>,
                "status": "<%== stage.getState() %>",
                "details_path": <%== stage_detail_tab_path(:pipeline_name => active_instance.getName(), :pipeline_counter => active_instance.getCounter(),
                :stage_name => stage.getName(), :stage_counter => stage.getCounter(), :only_path => true).to_json %>
              }<%== is_last_stage ? "" : "," %>
              <%- end -%>
            ]
          }<%== is_last_instance ? "" : "," %>
          <%- else -%>
          {
            "has_history": "false"
          }<%== is_last_instance ? "" : "," %>
          <%- end -%>
          <%- end -%>
        ],


        <%-# ====== ====== PREVIOUS RUN INFO (TO SHOW WHETHER THIS STAGE FAILED BEFORE ...) ====== ====== -%>
        <%- if pipeline_model.getLatestPipelineInstance().isAnyStageActive() -%>
        <%- active_stage = pipeline_model.getLatestPipelineInstance().activeStage() -%>
        <%- if active_stage.hasPreviousStage() -%>
        "previous_instance": { <%# TODO: Handle previously blurb. %>
          "result": <%== active_stage.getPreviousStage().getResult().to_s.to_json %>,
          "details_path": <%== stage_detail_path_for_identifier(active_stage.getPreviousStage().getIdentifier()).to_s.to_json %>,
          "pipeline_label": <%== active_stage.getPreviousStage().getIdentifier().getPipelineLabel().to_json %>
        },
        <%- end -%>
        <%- end -%>


        <%-# ====== ====== OPERATIONS (TRIGGER, PAUSE ...) ====== ====== -%>
        <%- is_paused = pipeline_model.getPausedInfo().isPaused() -%>
        "available_operations": [
        <%- if pipeline_model.canOperate() -%>
          {
            "operation": "trigger",
            "operation_path": <%== api_pipeline_action_path(:pipeline_name => pipeline_model.getName(), :action => "schedule").to_json %>
          },
          {
            "operation": "trigger_with_options",
            "operation_path": <%== pipeline_show_with_option_path.to_json %>
          },
          {
            "operation": <%== (is_paused ? "unpause" : "pause").to_json %>,
            "operation_path": <%== (is_paused ? unpause_pipeline_path(pipeline_model.getName()) : pause_pipeline_path(pipeline_model.getName())).to_json %>
          }
        <%- end -%>
        ],


        <%-# ====== ====== PAUSE INFORMATION (MESSAGE, PAUSED_BY ...) ====== ====== -%>
        "pause_info": {
          "is_paused": <%== is_paused.to_json + (is_paused ? "," : "") %>
          <%- if is_paused -%>
          "paused_by": <%== pipeline_model.getPausedInfo().getPauseBy().to_json %>,
          "message": <%== pipeline_model.getPausedInfo().getPauseCause().to_json %>
          <%- end -%>
        }
      }<%== is_last_pipeline ? "" : "," %>
      <%- end -%>
    ]
  }<%== is_last_group ? "" : "," %>
  <%- end -%>
]
{'fraction_non_alphanumeric': 0.20131626397403535, 'fraction_numerical': 0.0011720158672917419, 'mean_word_length': 2.693972693972694, 'pattern_counts': {'":': 70, '<': 131, '<?xml version=': 0, '>': 162, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2405800', 'n_tokens_mistral': 3674, 'n_tokens_neox': 3455, 'n_words': 419}