Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add latest goons report to boss page #956

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/features/bosses/do-fetch-bosses.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class BossesQuery extends APIQuery {
id
}
}
goonReports(gameMode: ${gameMode}) {
map {
id
}
timestamp
}
}`;

const bossesData = await this.graphqlRequest(query);
Expand All @@ -58,13 +64,18 @@ class BossesQuery extends APIQuery {
// only throw error if this is for prebuild or data wasn't returned
if (
prebuild || !bossesData.data ||
!bossesData.data.maps || !bossesData.data.maps.length
!bossesData.data.bosses || !bossesData.data.bosses.length
) {
return Promise.reject(new Error(bossesData.errors[0].message));
}
}

return bossesData.data.bosses;
return bossesData.data.bosses.map(boss => {
if (boss.normalizedName === 'death-knight') {
boss.reports = bossesData.data.goonReports;
}
return boss;
});
}
}

Expand Down
21 changes: 20 additions & 1 deletion src/pages/boss/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SmallItemTable from '../../components/small-item-table/index.js';
import DataTable from '../../components/data-table/index.js';
import PropertyList from '../../components/property-list/index.js';
import CheekiBreekiEffect from '../../components/cheeki-breeki-effect/index.js';
import { getRelativeTimeAndUnit } from '../../modules/format-duration.js';

import capitalize from '../../modules/capitalize-first.js';

Expand Down Expand Up @@ -347,6 +348,24 @@ function BossPage(params) {
}
}

let report = '';
if (bossData.reports?.length > 0) {
report = (
<div>
<div>{t('Most recent reports:')}</div>
<ul>
{bossData.reports.map((report, index) => {
const reportedMap = Object.values(allMaps).find(m => m.id === report.map.id);
let relativeTime = getRelativeTimeAndUnit(new Date(parseInt(report.timestamp)).getTime());
return (
<li key={`report-${index}`}>{reportedMap.name}: {t('{{val, relativetime}}', { val: relativeTime[0], range: relativeTime[1] })}</li>
);
})}
</ul>
</div>
);
}

// Return the main react component for the boss page
return [
<div className="display-wrapper" key={'boss-display-wrapper'}>
Expand Down Expand Up @@ -416,7 +435,7 @@ function BossPage(params) {
/>
</h2>
<PropertyList properties={bossProperties} />

{report}
<h2 key={'boss-loot-header'}>
{t('Special Boss Loot')}
<Icon
Expand Down
3 changes: 2 additions & 1 deletion src/translations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -607,5 +607,6 @@
"Convert one currency to another": "Convert one currency to another",
"Currency Converter": "Currency Converter",
"game_mode_regular": "Regular",
"game_mode_pve": "PVE"
"game_mode_pve": "PVE",
"Most recent reports:": "Most recent reports:"
}
Loading