use telemetry created at instead

This commit is contained in:
Adam Burgess 2024-12-26 19:35:23 +11:00
parent 36ca321a8c
commit 616e0d6c6c
No known key found for this signature in database

View File

@ -1,6 +1,6 @@
import Fastify from 'fastify' import Fastify from 'fastify'
import { Database } from './database.js'; import { Database } from './database.js';
import { MatchResponse, PlayerResponse, PubgApi } from './pubg-api.js'; import { Asset, MatchResponse, PlayerResponse, PubgApi } from './pubg-api.js';
import { Mutex } from 'async-mutex'; import { Mutex } from 'async-mutex';
import { render, renderToStringAsync } from 'preact-render-to-string'; import { render, renderToStringAsync } from 'preact-render-to-string';
import { h, Fragment } from 'preact'; import { h, Fragment } from 'preact';
@ -57,8 +57,12 @@ function getBotCount(match: MatchResponse) {
return { playerCount, botCount, humanCount: playerCount - botCount }; return { playerCount, botCount, humanCount: playerCount - botCount };
} }
function getChickenDinnerUrl(match: MatchResponse, player: PlayerResponse['data'][0]) { function getTelemetry(match: MatchResponse) {
const asset = match.included.find(i => i.type === 'asset')!; const asset = match.included.find(i => i.type === 'asset')!;
return asset!;
}
function getChickenDinnerUrl(asset: Asset, player: PlayerResponse['data'][0]) {
const url = asset.attributes.URL.substring('https://telemetry-cdn.pubg.com/bluehole-pubg/'.length).replace('-telemetry.json', ''); const url = asset.attributes.URL.substring('https://telemetry-cdn.pubg.com/bluehole-pubg/'.length).replace('-telemetry.json', '');
return `https://chickendinner.gg/${url}?follow=${player.attributes.name}`; return `https://chickendinner.gg/${url}?follow=${player.attributes.name}`;
} }
@ -101,7 +105,8 @@ li a { padding: 0 5px; }
var map = PubgApi.mapName(m.data.attributes.mapName); var map = PubgApi.mapName(m.data.attributes.mapName);
var rank = getRank(m, player.id); var rank = getRank(m, player.id);
var count = getBotCount(m); var count = getBotCount(m);
const date = dayjs(m.data.attributes.createdAt).add(m.data.attributes.duration, 's'); const telemetry = getTelemetry(m);
const date = dayjs(telemetry.attributes.createdAt);
return <div> return <div>
<ul> <ul>
@ -113,7 +118,7 @@ li a { padding: 0 5px; }
<li>Links: <li>Links:
<a href={`/match/${match.id}`}>Raw</a> <a href={`/match/${match.id}`}>Raw</a>
<a href={`https://pubglookup.com/players/steam/${player.attributes.name.toLowerCase()}/matches/${match.id}`}>PUBGLookup</a> <a href={`https://pubglookup.com/players/steam/${player.attributes.name.toLowerCase()}/matches/${match.id}`}>PUBGLookup</a>
<a href={getChickenDinnerUrl(m, player)}>map replay</a> <a href={getChickenDinnerUrl(telemetry, player)}>map replay</a>
</li> </li>
</ul> </ul>
</div> </div>