fix(feed): print weapons by name, not "ak47u entity"
The bridge names a kill's weapon by the held entity's short prefab name (ak47u.entity), and the feed printed it with the dots turned to spaces: "with ak47u entity". Every event read now gives the frame a weaponName (server/model/titles/weaponNames.js): the game's own English name for the 53 ranged weapons (guns, bows, crossbows, launchers, flamethrowers), read off the Oxide rig's item list on Rust 26139947, and for anything else the prefab name as words with its .entity/.weapon ending dropped. The site prints weaponName and falls back to the same stripping for an older server. The prefab name stays in the frame: the title lists count by it. Added at read, so stored rows are renamed too. No protocol change; the events route's Swagger description names the new field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -21,6 +21,7 @@ const raidableBases = require('../../raidableBases')
|
||||
const db = require('./events.db')
|
||||
const mapDb = require('../map/map.db')
|
||||
const serversDb = require('../servers/servers.db')
|
||||
const weaponNames = require('../titles/weaponNames')
|
||||
|
||||
/** Hard ceiling on a page, whatever a caller asks for. */
|
||||
const MAX_LIMIT = 200
|
||||
@@ -155,6 +156,13 @@ function shape(row) {
|
||||
frame = {}
|
||||
}
|
||||
|
||||
// The weapon as a page should print it (`model/titles/weaponNames.js`). Added
|
||||
// at read, so rows stored before this existed read the same as new ones, and
|
||||
// a later edit to the table renames every kill the feed still shows.
|
||||
if (typeof frame.weapon === 'string' && frame.weaponName === undefined) {
|
||||
frame.weaponName = weaponNames.nameOf(frame.weapon)
|
||||
}
|
||||
|
||||
return {
|
||||
id: Number(row.id),
|
||||
kind: row.kind,
|
||||
@@ -247,4 +255,4 @@ async function online(serverId) {
|
||||
}))
|
||||
}
|
||||
|
||||
module.exports = { recent, leaderboard, wipes, online, parseKinds, boundedLimit, MAX_LIMIT }
|
||||
module.exports = { recent, leaderboard, wipes, online, parseKinds, boundedLimit, shape, MAX_LIMIT }
|
||||
|
||||
Reference in New Issue
Block a user