From 4503246bcc50cf48c7f27f5d390ba109d28c9b36 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Wed, 3 Dec 2025 10:37:25 -0800 Subject: [PATCH] Add back multiplier for timings comparison and make history modal --- aocsync.py | 138 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 113 insertions(+), 25 deletions(-) diff --git a/aocsync.py b/aocsync.py index e287076..dc10cee 100755 --- a/aocsync.py +++ b/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: }} @@ -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' {user}{git_rev_html}\n' - html += """ + html += """ Speed Multiple + """ @@ -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""" @@ -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'
{hist_date}: {hist_time_str} ({hist_git})
') + hist_repo_url = hist.get('repo_url', '') + if hist_git != '-' and hist_repo_url: + hist_git_link = f'{hist_git}' + else: + hist_git_link = hist_git + history_items.append(f'
{hist_date}: {hist_time_str} ({hist_git_link})
') - history_html = f''' -
- History: - {''.join(history_items)} + history_modal = f''' + ''' - row_history_htmls.append(history_html) - history_link = f' 📊' + row_history_modals.append(history_modal) + history_link = f' 📊' html += f' {total_str}{history_link}\n' + # Add speed multiple column + if speed_multiple > 0: + speed_multiple_str = f"{speed_multiple:.2f}x" + else: + speed_multiple_str = "-" + html += f' {speed_multiple_str}\n' + html += """ """ - # 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 += """