mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 08:21:02 +02:00
Merge pull request #786 from ShaneMcGovernIE/find-mods-release-stats
Show feed-published release stats on Find Mods rows
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user