<commit_before><dom-module id="order-closed-summary">
    <style include="shared-styles"></style>
    <style>
        ul { list-style: none; margin: 0; padding: 0; }
        li > * { display: inline-block; margin: 0 0.25rem; }
    </style>
    <template>
        <paper-card heading="Order Closed">
            <div class="card-contents">
                <ul>
                <template is="dom-repeat" items="{{combinedItems(order)}}">
                    <li class="horizontal layout center">
                        <span>{{item.quantity}}<span>&times;</span></span>
                        <span>{{item.size}}<span>#</span></span>
                        <truncate-text strip="true" class="self-center" text="{{item.name}}"></truncate-text>
                    </li>
                </template>
                </ul>
            </div>
        </paper-card>
    </template>
</dom-module>
<script>
    Polymer({
        is: 'order-closed-summary',
        properties: {
            order: Object
        },
        combinedItems: function (order) {
            if (!order || !order.items) { return []; }
            var bycoffee = {};
            order.items.filter(i=>i.isCoffee).forEach(function (i) {
                if (i.coffee.name in bycoffee) {
                    bycoffee[i.coffee.name].quantity += parseInt(i.quantity);
                } else {
                    bycoffee[i.coffee.name] = {
                        quantity: parseInt(i.quantity),
                        size: parseInt(i.size),
                        name: i.coffee.name
                    };
                }
            });

            var ret = [];

            for (var k in bycoffee) {
                ret.push(bycoffee[k]);
            }

            return ret;
        }
    });
</script><commit_msg>Updated 'Order Closed' view to be more accurate and to paste better into email<commit_after><dom-module id="order-closed-summary">
    <style include="shared-styles"></style>
    <style>
        ul { list-style: none; margin: 0; padding: 0; }
        li > * { display: inline-block; margin: 0 0.25rem; }
    </style>
    <template>
        <paper-card heading="Order Closed">
            <div class="card-contents">
              <pre id="foremail">[[generateList(order)]]</pre>
<!--                 <ul>
                <template is="dom-repeat" items="{{combinedItems(order)}}">
                    <li class="horizontal layout center">
                        <span>{{item.quantity}}<span>&times;</span></span>
                        <span>{{item.size}}<span>#</span></span>
                        <truncate-text strip="true" class="self-center" text="{{item.name}}"></truncate-text>
                    </li>
                </template>
                </ul>
 -->            </div>
        </paper-card>
    </template>
</dom-module>
<script>
  Polymer({
    is: 'order-closed-summary',
    properties: {
      order: Object
    },
    generateList: function (order) {
      if (!order || !order.items) { return ''; }

      var bycoffee = {};

      order.items.filter(i=>i.isCoffee).forEach(function (i) {

        if (!(i.coffee.name in bycoffee)) {
          bycoffee[i.coffee.name] = {1: 0, 2: 0, 5: 0};
        }

        bycoffee[i.coffee.name][parseInt(i.size)] += parseInt(i.quantity);

      });

      var ret = [];
      var totalpounds = 0;

      for (var name in bycoffee) {
        for (var size in bycoffee[name]) {
          if (bycoffee[name][size] > 0) {
            ret.push({
              name: name,
              size: size,
              quantity: bycoffee[name][size]
            });
            totalpounds += size * bycoffee[name][size];
          }
        }
      }

      console.log('double check: total pounds => ' + totalpounds);

      return ret
        .sort((a,b) => a.name.localeCompare(b.name))
        .map(c => [c.quantity, '×', ' ', c.size, '#', ' ', c.name].join(''))
        .join('\n');
    }
  });
</script>

{'fraction_non_alphanumeric': 0.1653185035389282, 'fraction_numerical': 0.005055611729019211, 'mean_word_length': 1.5252074026802809, 'pattern_counts': {'":': 0, '<': 66, '<?xml version=': 0, '>': 74, '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': '4660222', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1138, 'n_words': 224}