Skip to content

Commit df10378

Browse files
committed
Homepage right cards auto-refresh
1 parent 7343c74 commit df10378

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

Diff for: vzdv-site/src/endpoints/homepage.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ async fn page_home(
3636
async fn snippet_online_controllers(
3737
State(state): State<Arc<AppState>>,
3838
) -> Result<Html<String>, AppError> {
39-
// cache this endpoint's returned data for 60 seconds
39+
// cache this endpoint's returned data for 30 seconds
4040
let cache_key = "ONLINE_CONTROLLERS";
4141
if let Some(cached) = state.cache.get(&cache_key) {
4242
let elapsed = Instant::now() - cached.inserted;
43-
if elapsed.as_secs() < 60 {
43+
if elapsed.as_secs() < 30 {
4444
return Ok(Html(cached.data));
4545
}
4646
state.cache.invalidate(&cache_key);

Diff for: vzdv-site/templates/changelog.jinja

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414

1515
<hr>
1616

17+
<div class="card shadow mb-3">
18+
<div class="card-body">
19+
<h5 class="card-title">2024-10-20</h5>
20+
<div class="card-text">
21+
<ul>
22+
<li>The right-side cards on the homepage auto-refresh every so often</li>
23+
</ul>
24+
</div>
25+
</div>
26+
</div>
27+
1728
<div class="card shadow mb-3">
1829
<div class="card-body">
1930
<h5 class="card-title">2024-10-19</h5>

Diff for: vzdv-site/templates/homepage/home.jinja

+13-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
</p>
1616
<div class="card shadow mb-2">
1717
<div class="card-body">
18-
<div id="events" hx-get="/events/upcoming" hx-trigger="load">
18+
<div
19+
id="events"
20+
hx-get="/events/upcoming"
21+
hx-trigger="load"
22+
>
1923
<p>Loading ...</p>
2024
</div>
2125
</div>
@@ -27,15 +31,19 @@
2731
<div
2832
id="online"
2933
hx-get="/home/online/controllers"
30-
hx-trigger="load"
34+
hx-trigger="load, every 1m"
3135
>
3236
<p>Loading ...</p>
3337
</div>
3438
</div>
3539
</div>
3640
<div class="card shadow mt-2">
3741
<div class="card-body">
38-
<div id="weather" hx-get="/home/weather" hx-trigger="load">
42+
<div
43+
id="weather"
44+
hx-get="/home/weather"
45+
hx-trigger="load, every 5m"
46+
>
3947
<p>Loading ...</p>
4048
</div>
4149
</div>
@@ -45,7 +53,7 @@
4553
<div
4654
id="flights"
4755
hx-get="/home/online/flights"
48-
hx-trigger="load"
56+
hx-trigger="load, every 1m"
4957
>
5058
<p>Loading ...</p>
5159
</div>
@@ -56,7 +64,7 @@
5664
<div
5765
id="cotm"
5866
hx-get="/home/cotm"
59-
hx-trigger="load"
67+
hx-trigger="load, every 1m"
6068
>
6169
<p>Loading ...</p>
6270
</div>

0 commit comments

Comments
 (0)