<commit_before><link rel="import" href="../../../../bower_components/polymer/polymer.html">

<link rel="import" href="../../things-content/things-resource-menu-content-behavior.html">

<dom-module id="things-pass-rate">
	<template>
		<style>
			:host {
				display: block;
				@apply(--layout-vertical);
				@apply(--layout-flex);
			}
			things-layout-gaia {
				@apply(--layout-flex);
			}
		</style>

    <things-ajax 
      auto
      id="resource-meta"
      method="GET"
      resource-url="[[menuMetaUrl]]"
      last-response="{{metaData}}">
    </things-ajax>

    <things-search-form 
      id="search-form"
      title="[[menuInfo.title]]"
      form-fields="[[searchFormFields]]" 
      action-url="[[menuInfo.resource_url]]"
      page="{{page}}"
      per-page="[[perPage]]"
      last-response="{{lastResponse}}">
    </things-search-form>

		<things-layout-gaia>
			<things-diy-based-grid
				content
				items="[[finalItems]]"
				buttons="[[buttons]]"
				class="flex"
				diy-grid-name="Pass-Rate">
			</things-diy-based-grid>
		</things-layout-gaia>    		
	</template>
	
	<script>
		Polymer({
			is: 'things-pass-rate',

			behaviors: [
				Things.ResourceMenuContentBehavior
			],			

			properties: {

				/**
				 * 통과율을 계산하기 이전의 데이터 object
				 */
				lastResponse: {
					type: Object,
					observer: '_lastResponseChanged'
				},

				/**
				 * 통과율을 계산하고 그리드에 넘겨줄 object
				 */
				finalItems: {
					type: Object
				}
			},

			/**
			 * 통과율을 계산하기 위한 함수
			 */
			_lastResponseChanged: function(data) {
				var finalItems = data.items;
				var inputQty;
				var repairQty;
				var reworkQty;
				var retryTotal;

				for(var i = 0; i < data.items.length; i++) {
					inputQty = finalItems[i].input_qty;
					repairQty = finalItems[i].repair_qty;
					reworkQty = finalItems[i].rework_qty;
					retryTotal = repairQty + reworkQty;
					finalItems[i].retry_total = retryTotal;

					//통과율
					finalItems[i].pass_rate = (((inputQty - retryTotal)/inputQty) * 100).toFixed(1);
					//100%중 통과율이 아닌 나머지 퍼센트
					finalItems[i].rest_rate = (100 - finalItems[i].pass_rate).toFixed(1);
				}
				this.finalItems = finalItems;
			}
		})
	</script>
</dom-module><commit_msg>things-pass-rate fix<commit_after><link rel="import" href="../../../../bower_components/polymer/polymer.html">

<link rel="import" href="../../things-content/things-resource-menu-content-behavior.html">

<dom-module id="things-pass-rate">
	<template>
		<style>
			:host {
				display: block;
				@apply(--layout-vertical);
				@apply(--layout-flex);
			}
			things-layout-gaia {
				@apply(--layout-flex);
			}
		</style>

    <things-ajax 
      auto
      id="resource-meta"
      method="GET"
      resource-url="[[menuMetaUrl]]"
      last-response="{{metaData}}">
    </things-ajax>

    <things-search-form 
      id="search-form"
      title="[[menuInfo.title]]"
      form-fields="[[searchFormFields]]" 
      action-url="[[menuInfo.resource_url]]"
      page="{{page}}"
      per-page="[[perPage]]"
      last-response="{{lastResponse}}">
    </things-search-form>

		<things-layout-gaia>
			<things-diy-based-grid
				content
				items="[[lastResponse]]"
				buttons="[[buttons]]"
				class="flex"
				diy-grid-name="Pass-Rate">
			</things-diy-based-grid>
		</things-layout-gaia>    		
	</template>
	
	<script>
		Polymer({
			is: 'things-pass-rate',

			behaviors: [
				Things.ResourceMenuContentBehavior
			],			

			properties: {

				/**
				 * ajax response
				 */
				lastResponse: {
					type: Object
				}
			}
		})
	</script>
</dom-module>
{'fraction_non_alphanumeric': 0.18069237264283705, 'fraction_numerical': 0.0033774275260343373, 'mean_word_length': 2.5153313550939664, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 39, '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': '10901', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1304, 'n_words': 178}