Skip to content

Commit

Permalink
Improve response for system trade data by commodity name
Browse files Browse the repository at this point in the history
  • Loading branch information
iaincollins committed Nov 9, 2024
1 parent 2b18f9f commit af3a162
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ardent-api",
"version": "4.4.0",
"version": "4.5.0",
"description": "Ardent API provides access to data submitted to EDDN",
"main": "index.js",
"scripts": {
Expand Down
30 changes: 29 additions & 1 deletion router/api/systems.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,35 @@ module.exports = (router) => {
const system = await getSystemByName(systemName)
if (!system) return NotFoundResponse(ctx, 'System not found')

const commodities = await dbAsync.all('SELECT * FROM trade.commodities WHERE systemName = @systemName COLLATE NOCASE AND commodityName = @commodityName COLLATE NOCASE', { systemName, commodityName })
const commodities = await dbAsync.all(`
SELECT
c.commodityId,
c.commodityName,
c.marketId,
c.stationName,
s.stationType,
s.distanceToArrival,
s.maxLandingPadSize,
c.systemName,
c.systemX,
c.systemY,
c.systemZ,
c.fleetCarrier,
c.buyPrice,
c.demand,
c.demandBracket,
c.meanPrice,
c.sellPrice,
c.stock,
c.stockBracket,
c.statusFlags,
c.updatedAt
FROM trade.commodities c
LEFT JOIN stations.stations s ON c.marketId = s.marketId
WHERE c.systemName = @systemName
AND c.commodityName = @commodityName
`, { systemName, commodityName })

ctx.body = commodities
})

Expand Down

0 comments on commit af3a162

Please sign in to comment.