mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-17 11:11:10 +02:00
Show feed-published release stats on Find Mods rows
A mod index can now publish three optional per-entry fields -- downloads (total across every release), first_release and last_release (ISO days) -- which the FIND MODS listing shows in the same gold line the MODS tab uses. The fields are additive by design: feeds that carry them stay readable by every build that predates them (schema_version stays 1), and feeds that do not render exactly as before. ModUpdate.statsLine builds the shared line; the MODS tab reuses it. Parser, formatting, and parse coverage are tested.
This commit is contained in:
@@ -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",
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user