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
+7
View File
@@ -174,6 +174,13 @@ local function parseEntry(raw)
conflicts = raw.conflicts,
thumbnail = str(raw.thumbnail),
description_url = str(raw.description_url),
-- Optional release stats a feed author can publish: total downloads
-- across all releases plus first/last release dates. Additive-only,
-- so a feed that carries them stays readable by every build that
-- predates them (and one that does not still renders fine here).
downloads = tonumber(raw.downloads),
first_release = str(raw.first_release),
last_release = str(raw.last_release),
latest = parseLatest(raw.latest),
update_check = str(raw.update_check) or "pending",
}
+20
View File
@@ -7,6 +7,8 @@ local ModUpdate = {}
ModUpdate.CACHE_TTL = 6 * 60 * 60 -- six hours
local Strings = require("src.core.Strings")
local function stripV(tag)
return (tostring(tag):gsub("^[vV]", ""))
end
@@ -237,6 +239,24 @@ function ModUpdate.formatCount(n)
return (s:gsub("^,", ""))
end
-- The one-line stats string both launcher panels show: "1,234 downloads
-- across all releases - Released 2024-05-31 - Updated 2026-07-01".
-- Each part is optional; nil everywhere means nil, so a row with no data
-- shows no line rather than a wrong "0".
function ModUpdate.statsLine(total, first, latest)
local parts = {}
if total ~= nil then
parts[#parts + 1] = Strings("%s downloads across all releases",
ModUpdate.formatCount(total))
end
if first or latest then
parts[#parts + 1] = Strings("Released %s - Updated %s",
first or "?", latest or "?")
end
if #parts == 0 then return nil end
return table.concat(parts, " - ")
end
-- ------- cache (options.modUpdateCache[repo])
local function cacheStore()