<commit_before><link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/paper-card/paper-card.html">
<link rel="import" href="../bower_components/paper-item/paper-item.html">
<link rel="import" href="../bower_components/paper-item/paper-item-body.html">
<script src="crbug-lib.js"></script>

<dom-module id="cz-regression-dash">

  <template>
    <style>
      paper-card .card-flex {
        display: flex;
        flex-wrap: wrap;
        align-content: flex-start;
      }

      paper-item {
        width: 50%;
        box-sizing: border-box;
      }

      a {
        font-size: 12px;
        color: #888;
        text-decoration: none;
      }

      .version {
        color: white;
        border-radius: 4px;
        padding: 0px 6px;
      }
    </style>
      <a href="{{crbugLink(components)}}" target="_blank">
        <paper-card heading="Regression Bugs" id="card">
          <div class="card-content">
            <div class='card-flex'>
              {{joinSpace(components)}}
              <template is="dom-repeat" items="{{regressionCounts(releases, regressionVersions)}}">
                <paper-item>
                  <paper-item-body one-line>
                    <div>
                      <span class="version" style="background-color: {{item.color}}">{{item.version}}</span> {{item.count}}
                    </div>
                  </paper-item-body>
                </paper-item>
              </template>
            </div>
          </div>
        </paper-card>
      </a>
  </template>

  <script>
  (function() {
    Polymer({
      is: "cz-regression-dash",

      properties: {
        releases: {
          type: 'Object',
          value: function() { return {}; },
        },
        components: {
          type: 'Object',
          value: function() { return []; },
          observer: "componentsChanged"
        },
        regressionVersions: {
          type: 'Object',
          value: function() { return []; },
        },
      },

      attached: function() {
        registerSource('cz-releases', {}, function(releases) {
          this.set('releases', releases);
        }.bind(this));
        registerSource('cz-config', 'components', function(components) {
          this.set('components', components.map(component => component.name));
        }.bind(this));
      },

      componentsChanged: function() {
        if (this.components.length == 0) {
          return;
        }
        registerSource('cz-issues', {type: 'Bug-Regression', component: this.components}, function(issues) {
          var regressionVersions = [];
          for (var issue of issues) {
            var version = null;
            for (var label of issue.labels) {
              if (label.indexOf('M-') == 0) {
                version = Number(label.substring(2));
              }
            }
            regressionVersions.push(version);
          }
          this.set('regressionVersions', regressionVersions);
        }.bind(this));
      },

      crbugLink: function(components) {
        return CrBug.queryURL({type: 'Bug-Regression', component: components});
      },

      joinSpace: list => list.join(' '),

      regressionCounts: function(releases, regressionVersions) {
        return [{
          version: '\u2264' + (releases.stable - 1),
          color: '#B90D00',
          count: regressionVersions.filter(version => version < releases.stable).length,
        }, {
          version: releases.stable,
          color: '#F44336',
          count: regressionVersions.filter(version => version == releases.stable).length,
        }, {
          version: releases.beta,
          color: '#FF9800',
          count: regressionVersions.filter(version => version == releases.beta).length,
        }, {
          version: releases.dev,
          color: '#4CAF50',
          count: regressionVersions.filter(version => version >= releases.dev).length,
        }, {
          version: '?',
          color: '#757575',
          count: regressionVersions.filter(version => version == null).length,
        }].filter(item => item.count > 0);
      },
    });
  })();
  </script>
</dom-module><commit_msg>regressionLabel<commit_after><link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/paper-card/paper-card.html">
<link rel="import" href="../bower_components/paper-item/paper-item.html">
<link rel="import" href="../bower_components/paper-item/paper-item-body.html">
<script src="crbug-lib.js"></script>

<dom-module id="cz-regression-dash">

  <template>
    <style>
      paper-card .card-flex {
        display: flex;
        flex-wrap: wrap;
        align-content: flex-start;
      }

      paper-item {
        width: 50%;
        box-sizing: border-box;
      }

      a {
        font-size: 12px;
        color: #888;
        text-decoration: none;
      }

      .label {
        color: white;
        border-radius: 4px;
        padding: 0px 6px;
      }
    </style>
      <a href="{{crbugLink(components)}}" target="_blank">
        <paper-card heading="Regression Bugs" id="card">
          <div class="card-content">
            <div class='card-flex'>
              {{joinSpace(components)}}
              <template is="dom-repeat" items="{{regressionCounts(releases, regressionVersions)}}">
                <paper-item>
                  <paper-item-body one-line>
                    <div>
                      <span class="label" style="background-color: {{item.color}}">{{item.label}}</span> {{item.count}}
                    </div>
                  </paper-item-body>
                </paper-item>
              </template>
            </div>
          </div>
        </paper-card>
      </a>
  </template>

  <script>
  (function() {
    Polymer({
      is: "cz-regression-dash",

      properties: {
        releases: {
          type: 'Object',
          value: function() { return {}; },
        },
        components: {
          type: 'Object',
          value: function() { return []; },
          observer: "componentsChanged"
        },
        regressionVersions: {
          type: 'Object',
          value: function() { return []; },
        },
      },

      attached: function() {
        registerSource('cz-releases', {}, function(releases) {
          this.set('releases', releases);
        }.bind(this));
        registerSource('cz-config', 'components', function(components) {
          this.set('components', components.map(component => component.name));
        }.bind(this));
      },

      componentsChanged: function() {
        if (this.components.length == 0) {
          return;
        }
        registerSource('cz-issues', {type: 'Bug-Regression', component: this.components}, function(issues) {
          var regressionVersions = [];
          for (var issue of issues) {
            var version = null;
            for (var label of issue.labels) {
              if (label.indexOf('M-') == 0) {
                version = Number(label.substring(2));
              }
            }
            regressionVersions.push(version);
          }
          this.set('regressionVersions', regressionVersions);
        }.bind(this));
      },

      crbugLink: function(components) {
        return CrBug.queryURL({type: 'Bug-Regression', component: components});
      },

      joinSpace: list => list.join(' '),

      regressionCounts: function(releases, regressionVersions) {
        return [{
          label: 'pre-stable \u2264' + (releases.stable - 1),
          color: '#B90D00',
          count: regressionVersions.filter(version => version < releases.stable).length,
        }, {
          label: 'stable ' + releases.stable,
          color: '#F44336',
          count: regressionVersions.filter(version => version == releases.stable).length,
        }, {
          label: 'beta ' + releases.beta,
          color: '#FF9800',
          count: regressionVersions.filter(version => version == releases.beta).length,
        }, {
          label: 'dev ' + releases.dev,
          color: '#4CAF50',
          count: regressionVersions.filter(version => version >= releases.dev).length,
        }, {
          label: 'unknown',
          color: '#757575',
          count: regressionVersions.filter(version => version == null).length,
        }].filter(item => item.count > 0);
      },
    });
  })();
  </script>
</dom-module>
{'fraction_non_alphanumeric': 0.15584261673382319, 'fraction_numerical': 0.009717942640436123, 'mean_word_length': 1.866508152173913, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 87, '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': '99438', 'n_tokens_mistral': 2468, 'n_tokens_neox': 2317, 'n_words': 438}