<commit_before>(function()
{
	var ORG_NAME_UPDATE_TIME = 3;
	var ORG_QUOTA_REFRESH_TIME = 60; // org quota는 60초에 한 번씩만 새로고침.
	var organizationQuota = null;
	var appQuotaSum = null;
	
	var orgQuotaRefreshTimer = null;
	
	var updateOrgQuota = function()
	{
		if(appQuotaSum != null && organizationQuota != null)
		{
			var text = '';
			var p = Math.floor((appQuotaSum / organizationQuota) * 100);
			if(p < 10)
				text = p + '%';
			else
				text = appQuotaSum + 'MB / ' + organizationQuota + 'MB (' + p + '%)';
			
			if(p > 50 && p <= 80)
				$('#quotaProgress').removeClass('progress-bar-danger').addClass('progress-bar-warning');
			else if(p > 80)
				$('#quotaProgress').removeClass('progress-bar-warning').addClass('progress-bar-danger');
			else
				$('#quotaProgress').removeClass('progress-bar-warning').removeClass('progress-bar-danger');
			
			$('#quotaProgress').removeClass('active').addClass('active').css('width', p + '%').text(text);
		}
	};
	
	var getOrgQuota = function(space)
	{
		CF.async({url : space.organization.entity.quota_definition_url}, function(result)
		{
			if(result)
			{
				if(result.entity)
				{
					organizationQuota = result.entity.memory_limit;
					updateOrgQuota();
				}
				else
				{
					$('#quotaProgress').css('width', '0%').removeClass('active').text(result.description ? result.description : JSON.stringify(result.error));
				}
			}
			else
			{
				$('#quotaProgress').css('width', '0%').removeClass('active').text('Organization quota is not found.');
			}
		});
	};
	
	_ee.on('space_selected', function(space)
	{
		$('#orgName span:first').text(space.organization.entity.name);
		$('#quotaProgress').addClass('active').css('width', '100%').text('Organization quota loading...');
		
		if(orgQuotaRefreshTimer)
		{
			clearInterval(orgQuotaRefreshTimer);
			orgQuotaRefreshTimer = null;
		}
		
		getOrgQuota(space);
		orgQuotaRefreshTimer = setInterval(function()
		{
			getOrgQuota(space);
		}, 1000 * ORG_QUOTA_REFRESH_TIME);
	});
	
	_ee.on('setAppList_done', function(appList)
	{
		appQuotaSum = 0;
		for(var i=0; i<appList.length; i++)
		{
			if(appList[i].entity.state == 'STARTED')
				appQuotaSum += appList[i].entity.memory;
		}
		
		updateOrgQuota();
	});
	
	$(document).ready(function()
	{
		$('#orgName span').on('click', function()
		{
			var prev = $(this).text();
			$(this).attr('contenteditable', '').focus();
			
			$(this).on('blur', function()
			{
				if(prev != $(this).text())
				{
					var space = $('#' + _global.hash.space).get(0).item;
					
					$('.org-name-description').text('Please, wait for update.').css('color', '#337ab7');
					CF.async({url : '/v2/organizations/' + space.organization.metadata.guid, method : 'PUT', form : {name : $(this).text()}}, function(result)
					{
						if(result)
						{
							if(result.entity)
							{
								$('#' + result.metadata.guid).prev().text(result.entity.name);
								$('.org-name-description').text('Updated.').css('color', '#337ab7');
								setTimeout(function()
								{
									$('.org-name-description').text('');
								}, 1000 * ORG_NAME_UPDATE_TIME);<commit_msg>Fixed bugs.<commit_after>(function()
{
	var ORG_NAME_UPDATE_TIME = 3;
	var ORG_QUOTA_REFRESH_TIME = 60; // org quota는 60초에 한 번씩만 새로고침.
	var organizationQuota = null;
	var appQuotaSum = null;
	
	var orgQuotaRefreshTimer = null;
	
	var updateOrgQuota = function()
	{
		if(appQuotaSum != null && organizationQuota != null)
		{
			var text = '';
			var p = Math.floor((appQuotaSum / organizationQuota) * 100);
			if(p < 10)
				text = p + '%';
			else
				text = appQuotaSum + 'MB / ' + organizationQuota + 'MB (' + p + '%)';
			
			if(p > 50 && p <= 80)
				$('#quotaProgress').removeClass('progress-bar-danger').addClass('progress-bar-warning');
			else if(p > 80)
				$('#quotaProgress').removeClass('progress-bar-warning').addClass('progress-bar-danger');
			else
				$('#quotaProgress').removeClass('progress-bar-warning').removeClass('progress-bar-danger');
			
			$('#quotaProgress').removeClass('active').addClass('active').css('width', p + '%').text(text);
		}
	};
	
	var getOrgQuota = function(space)
	{
		CF.async({url : space.organization.entity.quota_definition_url}, function(result)
		{
			if(result)
			{
				if(result.entity)
				{
					organizationQuota = result.entity.memory_limit;
					updateOrgQuota();
				}
				else
				{
					$('#quotaProgress').css('width', '0%').removeClass('active').text(result.description ? result.description : JSON.stringify(result.error));
				}
			}
			else
			{
				$('#quotaProgress').css('width', '0%').removeClass('active').text('Organization quota is not found.');
			}
		});
	};
	
	_ee.on('space_selected', function(space)
	{
		$('#orgName span:first').text(space.organization.entity.name);
		$('#quotaProgress').addClass('active').css('width', '100%').text('Organization quota loading...');
		
		if(orgQuotaRefreshTimer)
		{
			clearInterval(orgQuotaRefreshTimer);
			orgQuotaRefreshTimer = null;
		}
		
		getOrgQuota(space);
		orgQuotaRefreshTimer = setInterval(function()
		{
			getOrgQuota(space);
		}, 1000 * ORG_QUOTA_REFRESH_TIME);
	});
	
	_ee.on('setAppList_done', function(appList)
	{
		appQuotaSum = 0;
		for(var i=0; i<appList.length; i++)
		{
			if(appList[i].entity.state != 'STOPPED')
				appQuotaSum += appList[i].entity.memory * appList[i].entity.instances;
		}
		
		updateOrgQuota();
	});
	
	$(document).ready(function()
	{
		$('#orgName span').on('click', function()
		{
			var prev = $(this).text();
			$(this).attr('contenteditable', '').focus();
			
			$(this).on('blur', function()
			{
				if(prev != $(this).text())
				{
					var space = $('#' + _global.hash.space).get(0).item;
					
					$('.org-name-description').text('Please, wait for update.').css('color', '#337ab7');
					CF.async({url : '/v2/organizations/' + space.organization.metadata.guid, method : 'PUT', form : {name : $(this).text()}}, function(result)
					{
						if(result)
						{
							if(result.entity)
							{
								$('#' + result.metadata.guid).prev().text(result.entity.name);
								$('.org-name-description').text('Updated.').css('color', '#337ab7');
								setTimeout(function()
								{
									$('.org-name-description').text('');
								}, 1000 * ORG_NAME_UPDATE_TIME);
{'fraction_non_alphanumeric': 0.19724623759205892, 'fraction_numerical': 0.013128402177393531, 'mean_word_length': 3.503965392934391, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '521333', 'n_tokens_mistral': 2675, 'n_tokens_neox': 2141, 'n_words': 309}