<commit_before><% current_version = project.shared_versions.where("effective_date >= ?", Time.now).order("effective_date ASC").first %>

<% active = true %>
<% if Setting.plugin_project_overview[:stale_enable] %>
	<% active = (current_version && Redmine::Activity::Fetcher.new(User.current, :project => project, :with_subprojects => true).events(Time.now - Setting.plugin_project_overview[:stale_num_days].to_i.days, Time.now).any?) %>
<% end %>

<% if active || @stale || project.archived? || !project.active? %>

	<% actual_hours = project_overview_spent_time(project) %>
	<% estimated_hours = project_overview_estimated_time(project) %>

	<% planned_hours = nil %>
	<% if Setting.plugin_project_overview[:sow_estimate_field] %>
		<% planned_field_value = project.visible_custom_field_values.select { |p| p.custom_field_id == Setting.plugin_project_overview[:sow_estimate_field].to_i }.first %>
		<% planned_hours = planned_field_value.value.to_f if planned_field_value && !planned_field_value.value.blank? %>
	<% end %>

	<tr class="po_project">
		<td title="<%= project_full_title(project) %>"><%= link_to project.name, project_path(project) %></td>
		<% if Setting.plugin_project_overview[:stale_enable] %>
			<td align="center">
				<% if project.archived? %>
					<%= l(:project_status_archived) %>
				<% elsif !project.active? %>
					<%= l(:project_status_closed) %>
				<% elsif !active %>
					<%= l(:project_status_stale) %>
				<% else %>
					<%= l(:project_status_active) %>
				<% end %>
			</td>
		<% end %>
		<% if !!Setting.plugin_project_overview[:progress_by_version] %>
			<td align="center"><%= link_to(current_version.name, version_path(current_version)) if current_version %></td>
			<td align="center" class="po_progress">
				<% if current_version %>
					<%= progress_bar([current_version.closed_pourcent, current_version.completed_pourcent], :width => "100%") %>
				<% end %>
			</td>
			<td align="center"><%= current_version.due_date if current_version %></td>
		<% end %>
		<td align="center" class="po_progress">
			<%= progress_bar([project.completed_percent(:include_subprojects => true), 0], :width => "100%") %>
		</td>
		<td align="center">
			<% field_names = ['Project', 'Estimated Hours'] %>
			<% field_values = [project.name, estimated_hours] %>

			<% if Setting.plugin_project_overview[:sow_estimate_field] %>
				<% sowv = show_value(project.visible_custom_field_values.select { |p| p.custom_field_id == Setting.plugin_project_overview[:sow_estimate_field].to_i }.first) %>
				<% field_names << 'SOW/CR Hours'%>
				<% unless sowv.blank? %>
					<% field_values << sowv %>
				<% else %>
					<% field_values << 0 %>
				<% end %>
			<% end %>

			<% field_names << 'Actual Hours' %>
			<% field_values << actual_hours %>

			<div id="<%= "project_#{project.id}" %>"></div>
			<script type="text/javascript">
				google.load("visualization", "1", {packages:["corechart"]});
				google.setOnLoadCallback(drawChart);
				function drawChart() {
					var data = google.visualization.arrayToDataTable([
						[<%= raw field_names.map{|f| "'" + f.to_s + "'" }.join(",") %>],
						['<%= field_values[0] %>', <%= field_values[1..-1].join(",") %>]
					]);

					var options = {
						axisTitlesPosition: 'none',
						enableInteractivity: false,
						height: 20,
						width: 150,
						chartArea: {
							top: 0,
							height: "100%",
							width: "100%"
						},
						bar: {
							groupWidth: 20
						},
						hAxis: {
							minValue: 0,
							gridlines: {
								count: 3
							}
						},
						vAxis: {
							textPosition: 'none'
						}
					};

					var chart = new google.visualization.BarChart(document.getElementById('<%= "project_#{project.id}" %>'));
					chart.draw(data, options);
				}
			</script>
		</td>
		<td align="center"><%= estimated_hours.round(0) %></td>
		<td align="center"><%= actual_hours.round(0) %></td>

		<% hours_burned_percentage = (planned_hours || estimated_hours) == 0 ? 0 : (actual_hours/(planned_hours || estimated_hours))*100 %>

		<% num_tickets = project.self_and_descendants.map(&:issues).flatten.count %>
		<% ticket_completion_percentage = 100 %>
		<% if num_tickets > 0 %>
			<% ticket_completion_percentage = project.self_and_descendants.map(&:issues).flatten.collect(&:done_ratio).sum / num_tickets %>
		<% end %>

		<% if Setting.plugin_project_overview[:project_spi] %>
			<td align="center"><commit_msg>Use the new percentage value for a project in all places.<commit_after><% current_version = project.shared_versions.where("effective_date >= ?", Time.now).order("effective_date ASC").first %>

<% active = true %>
<% if Setting.plugin_project_overview[:stale_enable] %>
	<% active = (current_version && Redmine::Activity::Fetcher.new(User.current, :project => project, :with_subprojects => true).events(Time.now - Setting.plugin_project_overview[:stale_num_days].to_i.days, Time.now).any?) %>
<% end %>

<% if active || @stale || project.archived? || !project.active? %>

	<% actual_hours = project_overview_spent_time(project) %>
	<% estimated_hours = project_overview_estimated_time(project) %>

	<% planned_hours = nil %>
	<% if Setting.plugin_project_overview[:sow_estimate_field] %>
		<% planned_field_value = project.visible_custom_field_values.select { |p| p.custom_field_id == Setting.plugin_project_overview[:sow_estimate_field].to_i }.first %>
		<% planned_hours = planned_field_value.value.to_f if planned_field_value && !planned_field_value.value.blank? %>
	<% end %>

	<% num_tickets = project.self_and_descendants.map(&:issues).flatten.count %>
	<% ticket_completion_percentage = 100 %>
	<% if num_tickets > 0 %>
		<% ticket_completion_percentage = project.self_and_descendants.map(&:issues).flatten.collect(&:done_ratio).sum / num_tickets %>
	<% end %>

	<tr class="po_project">
		<td title="<%= project_full_title(project) %>"><%= link_to project.name, project_path(project) %></td>
		<% if Setting.plugin_project_overview[:stale_enable] %>
			<td align="center">
				<% if project.archived? %>
					<%= l(:project_status_archived) %>
				<% elsif !project.active? %>
					<%= l(:project_status_closed) %>
				<% elsif !active %>
					<%= l(:project_status_stale) %>
				<% else %>
					<%= l(:project_status_active) %>
				<% end %>
			</td>
		<% end %>
		<% if !!Setting.plugin_project_overview[:progress_by_version] %>
			<td align="center"><%= link_to(current_version.name, version_path(current_version)) if current_version %></td>
			<td align="center" class="po_progress">
				<% if current_version %>
					<%= progress_bar([current_version.closed_pourcent, current_version.completed_pourcent], :width => "100%") %>
				<% end %>
			</td>
			<td align="center"><%= current_version.due_date if current_version %></td>
		<% end %>
		<td align="center" class="po_progress">
			<%= progress_bar([ticket_completion_percentage, 0], :width => "100%") %>
		</td>
		<td align="center">
			<% field_names = ['Project', 'Estimated Hours'] %>
			<% field_values = [project.name, estimated_hours] %>

			<% if Setting.plugin_project_overview[:sow_estimate_field] %>
				<% sowv = show_value(project.visible_custom_field_values.select { |p| p.custom_field_id == Setting.plugin_project_overview[:sow_estimate_field].to_i }.first) %>
				<% field_names << 'SOW/CR Hours'%>
				<% unless sowv.blank? %>
					<% field_values << sowv %>
				<% else %>
					<% field_values << 0 %>
				<% end %>
			<% end %>

			<% field_names << 'Actual Hours' %>
			<% field_values << actual_hours %>

			<div id="<%= "project_#{project.id}" %>"></div>
			<script type="text/javascript">
				google.load("visualization", "1", {packages:["corechart"]});
				google.setOnLoadCallback(drawChart);
				function drawChart() {
					var data = google.visualization.arrayToDataTable([
						[<%= raw field_names.map{|f| "'" + f.to_s + "'" }.join(",") %>],
						['<%= field_values[0] %>', <%= field_values[1..-1].join(",") %>]
					]);

					var options = {
						axisTitlesPosition: 'none',
						enableInteractivity: false,
						height: 20,
						width: 150,
						chartArea: {
							top: 0,
							height: "100%",
							width: "100%"
						},
						bar: {
							groupWidth: 20
						},
						hAxis: {
							minValue: 0,
							gridlines: {
								count: 3
							}
						},
						vAxis: {
							textPosition: 'none'
						}
					};

					var chart = new google.visualization.BarChart(document.getElementById('<%= "project_#{project.id}" %>'));
					chart.draw(data, options);
				}
			</script>
		</td>
		<td align="center"><%= estimated_hours.round(0) %></td>
		<td align="center"><%= actual_hours.round(0) %></td>

		<% hours_burned_percentage = (planned_hours || estimated_hours) == 0 ? 0 : (actual_hours/(planned_hours || estimated_hours))*100 %>

		<% if Setting.plugin_project_overview[:project_spi] %>
			<td align="center">
{'fraction_non_alphanumeric': 0.18203443588581786, 'fraction_numerical': 0.008835523334843678, 'mean_word_length': 3.9937782805429864, 'pattern_counts': {'":': 0, '<': 193, '<?xml version=': 0, '>': 186, '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': '912802', 'n_tokens_mistral': 3830, 'n_tokens_neox': 2895, 'n_words': 468}