Skip to content

Commit e1ac16c

Browse files
committed
fix: use whenLastUpdate instead of whenLastCheck for stats
whenLastCheck is set on every ping including subscriptions, which inflates the count. whenLastUpdate only gets set when a feed actually changes, giving a more accurate "feeds changed" metric.
1 parent 7f0323c commit e1ac16c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

services/stats.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function getStats() {
1616
} catch {
1717
return {
1818
generatedAt: null,
19-
feedsPingedLast7Days: 0,
19+
feedsChangedLast7Days: 0,
2020
feedsWithSubscribers: 0,
2121
uniqueAggregators: 0,
2222
totalActiveSubscriptions: 0,
@@ -33,18 +33,18 @@ async function generateStats() {
3333

3434
const data = jsonStore.getData();
3535

36-
let feedsPingedLast7Days = 0;
36+
let feedsChangedLast7Days = 0;
3737
let totalActiveSubscriptions = 0;
3838
const hostnames = new Set();
3939
const protocolBreakdown = { 'http-post': 0, 'https-post': 0, 'xml-rpc': 0 };
4040
const feedCounts = [];
4141

4242
for (const [feedUrl, entry] of Object.entries(data)) {
43-
// Count feeds pinged in last 7 days
44-
if (entry.resource?.whenLastCheck) {
45-
const lastCheck = new Date(entry.resource.whenLastCheck);
46-
if (lastCheck >= sevenDaysAgo) {
47-
feedsPingedLast7Days++;
43+
// Count feeds changed in last 7 days
44+
if (entry.resource?.whenLastUpdate) {
45+
const lastUpdate = new Date(entry.resource.whenLastUpdate);
46+
if (lastUpdate >= sevenDaysAgo) {
47+
feedsChangedLast7Days++;
4848
}
4949
}
5050

@@ -84,7 +84,7 @@ async function generateStats() {
8484

8585
const stats = {
8686
generatedAt: dayjs().utc().format(),
87-
feedsPingedLast7Days,
87+
feedsChangedLast7Days,
8888
feedsWithSubscribers: feedCounts.length,
8989
uniqueAggregators: hostnames.size,
9090
totalActiveSubscriptions,

views/stats.handlebars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<h2>Overview</h2>
1313
<table class="stats-table">
1414
<tr>
15-
<td>Feeds pinged in last 7 days</td>
16-
<td>{{feedsPingedLast7Days}}</td>
15+
<td>Feeds changed in last 7 days</td>
16+
<td>{{feedsChangedLast7Days}}</td>
1717
</tr>
1818
<tr>
1919
<td>Feeds with subscribers</td>

0 commit comments

Comments
 (0)