Skip to content

Commit abeb415

Browse files
committed
feat: show builds over 30 days, not 7 days hourly
Signed-off-by: Paul Spooren <[email protected]>
1 parent b8cd24a commit abeb415

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

asu/routers/stats.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ def get_redis_ts():
1111
return get_redis_client().ts()
1212

1313

14-
@router.get("/builds-per-hour")
15-
def get_builds_per_hour():
14+
@router.get("/builds-per-day")
15+
def get_builds_per_day():
1616
ts = get_redis_ts()
1717
now = int(datetime.utcnow().timestamp() * 1000)
18-
start = now - 7 * 24 * 60 * 60 * 1000 # last 24 hours
18+
start = now - 30 * 24 * 60 * 60 * 1000 # last 30 days
1919

2020
# aggregate all time series labeled with stats=builds
2121
results = ts.mrange(
@@ -24,24 +24,24 @@ def get_builds_per_hour():
2424
filters=["stats=builds"],
2525
with_labels=False,
2626
aggregation_type="sum",
27-
bucket_size_msec=3600000, # 1 hour
27+
bucket_size_msec=86400000, # 1 day (24 hours)
2828
)
2929

3030
# create a map from timestamp to build count
31-
hourly_counts = {}
31+
daily_counts = {}
3232

3333
for entry in results:
3434
data = list(entry.values())[0][1]
3535
for ts, value in data:
36-
hourly_counts[ts] = hourly_counts.get(ts, 0) + int(value)
36+
daily_counts[ts] = daily_counts.get(ts, 0) + int(value)
3737

3838
# sort by timestamp
39-
sorted_data = sorted(hourly_counts.items())
39+
sorted_data = sorted(daily_counts.items())
4040

4141
labels = [datetime.utcfromtimestamp(ts / 1000).isoformat() for ts, _ in sorted_data]
4242
values = [count for _, count in sorted_data]
4343

4444
return {
4545
"labels": labels,
46-
"datasets": [{"label": "Builds per hour", "data": values}],
46+
"datasets": [{"label": "Builds per day", "data": values}],
4747
}

asu/templates/overview.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h2>About the Sysupgrade Server</h2>
7373

7474
{% if server_stats %}
7575
<div class="grid-item">
76-
<h2>Builds per Hour (last 7 days)</h2>
76+
<h2>Builds per Day (last 30 days)</h2>
7777
<canvas id="buildsChart" width="600" height="300"></canvas>
7878
</div>
7979
{% endif %}
@@ -107,7 +107,7 @@ <h2>Builds per Hour (last 7 days)</h2>
107107
<script src="static/chart.js"></script>
108108
<script>
109109
async function loadBuildStats() {
110-
const response = await fetch("/api/v1/builds-per-hour");
110+
const response = await fetch("/api/v1/builds-per-day");
111111
const data = await response.json();
112112

113113
const countChart = new Chart(document.getElementById("buildsChart"), {

0 commit comments

Comments
 (0)