Merge pull request #786 from ShaneMcGovernIE/find-mods-release-stats

Show feed-published release stats on Find Mods rows
This commit is contained in:
bryanthaboi
2026-08-04 08:00:46 -04:00
committed by GitHub
6 changed files with 85 additions and 7 deletions
+21
View File
@@ -110,6 +110,27 @@ do
"the release asset URL survives parsing")
eq(m.permissions[1], "engine_internals", "permissions are kept")
eq(m.update_check, "ok", "update_check is kept")
check(m.downloads == nil and m.first_release == nil and m.last_release == nil,
"a feed without release stats parses them as absent")
end
-- release stats a feed can publish: total downloads and first/last dates
-- ride along additively, so a feed carrying them stays readable by every
-- build that predates them
do
local withStats = {}
for k, v in pairs(NUZLOCKE) do withStats[k] = v end
withStats.downloads = 1234
withStats.first_release = "2024-05-31"
withStats.last_release = "2026-07-01"
local index = ModIndex.parse(feed({ withStats }))
local m = index.mods[1]
eq(m.downloads, 1234, "total downloads are kept")
eq(m.first_release, "2024-05-31", "first release date is kept")
eq(m.last_release, "2026-07-01", "last release date is kept")
withStats.downloads = "9999"
m = ModIndex.parse(feed({ withStats })).mods[1]
eq(m.downloads, 9999, "numeric-string downloads are coerced")
end
-- schema_version is a contract, not a hint: an unknown one is refused rather
+16
View File
@@ -183,6 +183,22 @@ eq(ModUpdate.formatCount("12345"), "12,345", "numeric strings are accepted")
eq(ModUpdate.formatCount(nil), "0", "nil formats as zero")
eq(ModUpdate.formatCount("garbage"), "0", "garbage formats as zero")
-- statsLine: the shared launcher row line, part by part
eq(ModUpdate.statsLine(1234567, "2024-05-31", "2026-07-01"),
"1,234,567 downloads across all releases - Released 2024-05-31 - Updated 2026-07-01",
"full stats line")
eq(ModUpdate.statsLine(82, nil, nil),
"82 downloads across all releases",
"downloads alone")
eq(ModUpdate.statsLine(nil, "2024-05-31", "2026-07-01"),
"Released 2024-05-31 - Updated 2026-07-01",
"dates alone")
eq(ModUpdate.statsLine(0, nil, nil),
"0 downloads across all releases",
"a real zero still shows")
check(ModUpdate.statsLine(nil, nil, nil) == nil,
"no data at all means no line")
-- cacheUsable: a cache entry from before downloads existed must not be
-- trusted, everything current is
do