Add back multiplier for timings comparison and make history modal
This commit is contained in:
parent
d1bdecf5e7
commit
4503246bcc
138
aocsync.py
138
aocsync.py
@ -1052,21 +1052,66 @@ class HTMLGenerator:
|
||||
text-decoration: underline;
|
||||
}}
|
||||
|
||||
.history-data {{
|
||||
.modal {{
|
||||
display: none;
|
||||
margin-top: 5px;
|
||||
padding: 5px;
|
||||
background: #f0f0f0;
|
||||
border-radius: 4px;
|
||||
font-size: 0.8em;
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
}}
|
||||
|
||||
.history-data.show {{
|
||||
.modal.show {{
|
||||
display: block;
|
||||
}}
|
||||
|
||||
.modal-content {{
|
||||
background-color: #fefefe;
|
||||
margin: 5% auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #888;
|
||||
border-radius: 8px;
|
||||
width: 80%;
|
||||
max-width: 600px;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
position: relative;
|
||||
}}
|
||||
|
||||
.modal-header {{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 2px solid #667eea;
|
||||
}}
|
||||
|
||||
.modal-title {{
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}}
|
||||
|
||||
.modal-close {{
|
||||
color: #aaa;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
line-height: 20px;
|
||||
}}
|
||||
|
||||
.modal-close:hover,
|
||||
.modal-close:focus {{
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
}}
|
||||
|
||||
.history-item {{
|
||||
padding: 2px 0;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}}
|
||||
|
||||
@ -1115,11 +1160,26 @@ class HTMLGenerator:
|
||||
}}
|
||||
</style>
|
||||
<script>
|
||||
function toggleHistory(user, year, day, part) {{
|
||||
function showHistory(user, year, day, part) {{
|
||||
const id = `history-${{user}}-${{year}}-${{day}}-${{part}}`;
|
||||
const elem = document.getElementById(id);
|
||||
if (elem) {{
|
||||
elem.classList.toggle('show');
|
||||
const modal = document.getElementById(id);
|
||||
if (modal) {{
|
||||
modal.classList.add('show');
|
||||
}}
|
||||
}}
|
||||
|
||||
function closeHistory(user, year, day, part) {{
|
||||
const id = `history-${{user}}-${{year}}-${{day}}-${{part}}`;
|
||||
const modal = document.getElementById(id);
|
||||
if (modal) {{
|
||||
modal.classList.remove('show');
|
||||
}}
|
||||
}}
|
||||
|
||||
// Close modal when clicking outside of it
|
||||
window.onclick = function(event) {{
|
||||
if (event.target.classList.contains('modal')) {{
|
||||
event.target.classList.remove('show');
|
||||
}}
|
||||
}}
|
||||
</script>
|
||||
@ -1182,8 +1242,10 @@ class HTMLGenerator:
|
||||
if not user_info[user]['repo_url']:
|
||||
user_info[user]['repo_url'] = time_data.get('repo_url', '')
|
||||
|
||||
# Find fastest times per day/part for highlighting
|
||||
# Find fastest and slowest times per day/part for highlighting and speed multiple
|
||||
fastest_times = {}
|
||||
slowest_times = {}
|
||||
speed_multiples = {}
|
||||
for day, part in day_part_combos:
|
||||
part_data = data[year][day][part]
|
||||
times = []
|
||||
@ -1196,6 +1258,11 @@ class HTMLGenerator:
|
||||
times.append(total_time)
|
||||
if times:
|
||||
fastest_times[(day, part)] = min(times)
|
||||
slowest_times[(day, part)] = max(times)
|
||||
if fastest_times[(day, part)] > 0:
|
||||
speed_multiples[(day, part)] = slowest_times[(day, part)] / fastest_times[(day, part)]
|
||||
else:
|
||||
speed_multiples[(day, part)] = 0
|
||||
|
||||
# Create table with transposed structure
|
||||
html += """
|
||||
@ -1220,7 +1287,8 @@ class HTMLGenerator:
|
||||
|
||||
html += f' <th>{user}{git_rev_html}</th>\n'
|
||||
|
||||
html += """ </tr>
|
||||
html += """ <th>Speed Multiple</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
"""
|
||||
@ -1229,7 +1297,8 @@ class HTMLGenerator:
|
||||
for day, part in day_part_combos:
|
||||
part_data = data[year][day][part]
|
||||
fastest_time = fastest_times.get((day, part), 0)
|
||||
row_history_htmls = []
|
||||
speed_multiple = speed_multiples.get((day, part), 0)
|
||||
row_history_modals = []
|
||||
|
||||
html += f"""
|
||||
<tr>
|
||||
@ -1291,25 +1360,44 @@ class HTMLGenerator:
|
||||
|
||||
hist_git = hist.get('git_rev', '')[:7] if hist.get('git_rev') else '-'
|
||||
hist_date = hist.get('timestamp', '')[:16] if hist.get('timestamp') else ''
|
||||
history_items.append(f'<div class="history-item">{hist_date}: {hist_time_str} ({hist_git})</div>')
|
||||
hist_repo_url = hist.get('repo_url', '')
|
||||
if hist_git != '-' and hist_repo_url:
|
||||
hist_git_link = f'<a href="{hist_repo_url.rstrip("/")}/commit/{hist.get("git_rev", "")}" target="_blank">{hist_git}</a>'
|
||||
else:
|
||||
hist_git_link = hist_git
|
||||
history_items.append(f'<div class="history-item">{hist_date}: {hist_time_str} ({hist_git_link})</div>')
|
||||
|
||||
history_html = f'''
|
||||
<div class="history-data" id="history-{user}-{year}-{day}-{part}">
|
||||
<strong>History:</strong>
|
||||
{''.join(history_items)}
|
||||
history_modal = f'''
|
||||
<div id="history-{user}-{year}-{day}-{part}" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<div class="modal-title">History: {user} - Year {year} Day {day} Part {part}</div>
|
||||
<span class="modal-close" onclick="closeHistory('{user}', {year}, {day}, {part})">×</span>
|
||||
</div>
|
||||
<div>
|
||||
{''.join(history_items)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
'''
|
||||
row_history_htmls.append(history_html)
|
||||
history_link = f' <span class="history-link" onclick="toggleHistory(\'{user}\', {year}, {day}, {part})">📊</span>'
|
||||
row_history_modals.append(history_modal)
|
||||
history_link = f' <span class="history-link" onclick="showHistory(\'{user}\', {year}, {day}, {part})">📊</span>'
|
||||
|
||||
html += f' <td class="time {cell_class}">{total_str}{history_link}</td>\n'
|
||||
|
||||
# Add speed multiple column
|
||||
if speed_multiple > 0:
|
||||
speed_multiple_str = f"{speed_multiple:.2f}x"
|
||||
else:
|
||||
speed_multiple_str = "-"
|
||||
html += f' <td class="time">{speed_multiple_str}</td>\n'
|
||||
|
||||
html += """ </tr>
|
||||
"""
|
||||
|
||||
# Add history HTML after the row
|
||||
for hist_html in row_history_htmls:
|
||||
html += hist_html
|
||||
# Add history modals after the row
|
||||
for hist_modal in row_history_modals:
|
||||
html += hist_modal
|
||||
|
||||
html += """ </tbody>
|
||||
</table>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user