<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codelens - Hotspot Analysis</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4"></script>
<style>
:root {
--bg-primary: #0d1117; --bg-secondary: #161b22; --bg-tertiary: #21262d;
--text-primary: #f0f6fc; --text-secondary: #8b949e;
--accent-blue: #58a6ff; --accent-green: #3fb950; --accent-yellow: #d29922;
--accent-purple: #a371f7; --accent-red: #f85149;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; }
.container { max-width: 1400px; margin: 0 auto; padding: 2rem; }
header { text-align: center; margin-bottom: 3rem; padding-bottom: 2rem; border-bottom: 1px solid var(--bg-tertiary); }
header h1 { font-size: 2.5rem; background: linear-gradient(135deg, var(--accent-red), var(--accent-yellow)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.5rem; margin-bottom: 3rem; }
.stat-card { background: var(--bg-secondary); border-radius: 12px; padding: 1.5rem; text-align: center; border: 1px solid var(--bg-tertiary); }
.stat-card .value { font-size: 2rem; font-weight: bold; color: var(--accent-green); }
.stat-card .label { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.5rem; }
.charts-section { display: grid; grid-template-columns: 1fr; gap: 2rem; margin-bottom: 3rem; }
.chart-container { background: var(--bg-secondary); border-radius: 12px; padding: 1.5rem; border: 1px solid var(--bg-tertiary); }
.chart-container h3 { margin-bottom: 1rem; color: var(--text-secondary); }
table { width: 100%; border-collapse: collapse; background: var(--bg-secondary); border-radius: 12px; overflow: hidden; }
th, td { padding: 0.8rem 1rem; text-align: left; border-bottom: 1px solid var(--bg-tertiary); }
th { background: var(--bg-tertiary); font-weight: 600; color: var(--text-secondary); }
tr:hover { background: var(--bg-tertiary); }
.risk-high { color: var(--accent-red); font-weight: bold; }
.risk-med { color: var(--accent-yellow); font-weight: bold; }
.risk-low { color: var(--accent-green); }
.progress-bar { height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; min-width: 80px; }
.progress-bar .fill { height: 100%; border-radius: 4px; }
footer { text-align: center; padding: 2rem; color: var(--text-secondary); border-top: 1px solid var(--bg-tertiary); margin-top: 3rem; }
</style>
</head>
<body>
<div class="container">
<header>
<h1>Hotspot Analysis</h1>
<p style="color: var(--text-secondary)">Generated: {{ generated_at }}</p>
</header>
<section class="stats-grid">
<div class="stat-card">
<div class="value">{{ since }}</div>
<div class="label">Time Window</div>
</div>
<div class="stat-card">
<div class="value">{{ total_commits }}</div>
<div class="label">Total Commits</div>
</div>
<div class="stat-card">
<div class="value">{{ files.len() }}</div>
<div class="label">Hotspots Found</div>
</div>
</section>
{% if !files.is_empty() %}
<section class="charts-section">
<div class="chart-container">
<h3>Top Hotspots (Score)</h3>
<canvas id="hotspotChart"></canvas>
</div>
</section>
<section>
<h2 style="margin-bottom: 1rem">Hotspot Details</h2>
<table>
<thead>
<tr><th>File</th><th>Language</th><th>Commits</th><th>+/-</th><th>Complexity</th><th>Score</th><th>Risk</th><th></th></tr>
</thead>
<tbody>
{% for h in files %}
<tr>
<td><strong>{{ h.path }}</strong></td>
<td>{{ h.language }}</td>
<td>{{ h.commits }}</td>
<td>+{{ h.lines_added }}/-{{ h.lines_deleted }}</td>
<td>{{ h.cyclomatic }}</td>
<td>{{ h.score_display }}</td>
<td class="{% if h.risk == "HIGH" %}risk-high{% else if h.risk == "MED" %}risk-med{% else %}risk-low{% endif %}">{{ h.risk }}</td>
<td><div class="progress-bar"><div class="fill" style="width: {{ h.score_pct }}%; background: {% if h.risk == "HIGH" %}var(--accent-red){% else if h.risk == "MED" %}var(--accent-yellow){% else %}var(--accent-green){% endif %}"></div></div></td>
</tr>
{% endfor %}
</tbody>
</table>
</section>
{% else %}
<section style="text-align: center; padding: 3rem; color: var(--text-secondary);">
<p>No hotspots found in this time window.</p>
</section>
{% endif %}
<footer>
<p>Generated by <a href="https://github.com/DropFan/codelens" style="color: var(--accent-blue)"><strong>Codelens</strong></a> by <a href="https://github.com/DropFan" style="color: var(--accent-blue)">Tiger</a> | High-performance code analysis tool powered by Rust</p>
</footer>
</div>
{% if !files.is_empty() %}
<script>
const topN = [
{% for h in files %}
{ name: "{{ h.path }}", score: {{ h.score_display }} },
{% endfor %}
].slice(0, 15);
new Chart(document.getElementById('hotspotChart'), {
type: 'bar',
data: {
labels: topN.map(d => d.name.split('/').pop()),
datasets: [{
label: 'Hotspot Score',
data: topN.map(d => d.score),
backgroundColor: topN.map(d => d.score > 0.7 ? '#f85149' : d.score > 0.3 ? '#d29922' : '#3fb950'),
borderRadius: 4,
}]
},
options: {
indexAxis: 'y', responsive: true,
scales: {
x: { max: 1.0, ticks: { color: '#8b949e' }, grid: { color: '#21262d' } },
y: { ticks: { color: '#f0f6fc', font: { size: 11 } }, grid: { display: false } }
},
plugins: { legend: { display: false }, tooltip: { callbacks: { title: (items) => topN[items[0].dataIndex].name } } }
}
});
</script>
{% endif %}
</body>
</html>