mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-04-18 15:47:49 -05:00
Add X-Rank leaderboard data
This commit is contained in:
parent
63a4654481
commit
8b2cd71e5f
|
|
@ -3,6 +3,7 @@ import StageScheduleUpdater from "./updaters/StageScheduleUpdater.mjs";
|
|||
import CoopUpdater from "./updaters/CoopUpdater.mjs";
|
||||
import FestivalUpdater from "./updaters/FestivalUpdater.mjs";
|
||||
import { regionTokens } from "../splatnet/NsoClient.mjs";
|
||||
import XRankUpdater from "./updaters/XRankUpdater.mjs";
|
||||
|
||||
function updaters() {
|
||||
const tokens = regionTokens();
|
||||
|
|
@ -15,6 +16,8 @@ function updaters() {
|
|||
tokens.EU && new FestivalUpdater('EU'),
|
||||
tokens.JP && new FestivalUpdater('JP'),
|
||||
tokens.AP && new FestivalUpdater('AP'),
|
||||
new XRankUpdater('Tentatek', 'ATLANTIC'),
|
||||
new XRankUpdater('Takoroka', 'PACIFIC'),
|
||||
].filter(u => u);
|
||||
}
|
||||
|
||||
|
|
|
|||
49
app/data/updaters/XRankDetailUpdater.mjs
Normal file
49
app/data/updaters/XRankDetailUpdater.mjs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import prefixedConsole from "../../common/prefixedConsole.mjs";
|
||||
import DataUpdater from "./DataUpdater.mjs";
|
||||
|
||||
export default class XRankDetailUpdater extends DataUpdater
|
||||
{
|
||||
name = 'X-Rank Detail';
|
||||
filename = 'xrank/xrank.detail';
|
||||
|
||||
imagePaths = [
|
||||
'$..image.url',
|
||||
'$..image2d.url',
|
||||
'$..image2dThumbnail.url',
|
||||
'$..image3d.url',
|
||||
'$..image3dThumbnail.url',
|
||||
];
|
||||
|
||||
constructor(seasonId, xRankDetailType) {
|
||||
super();
|
||||
|
||||
this.seasonId = seasonId;
|
||||
this.xRankDetailType = xRankDetailType;
|
||||
|
||||
this.filename += `.${seasonId}.${xRankDetailType.key}`;
|
||||
}
|
||||
|
||||
get console() {
|
||||
this._console ??= prefixedConsole('Updater', this.region, this.name, this.seasonId, this.xRankDetailType.name);
|
||||
|
||||
return this._console;
|
||||
}
|
||||
|
||||
async getData(locale) {
|
||||
let result;
|
||||
let edges = [];
|
||||
let dataKey = this.xRankDetailType.dataKey;
|
||||
|
||||
// Get each page's data
|
||||
let pages = this.splatnet(locale).getXRankingDetailPages(this.xRankDetailType, this.seasonId);
|
||||
for await (let page of pages) {
|
||||
result = page;
|
||||
edges.push(...page.data.node[dataKey].edges);
|
||||
}
|
||||
|
||||
// Replace the list of nodes with the complete list from all pages
|
||||
result.data.node[dataKey].edges = edges;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
47
app/data/updaters/XRankUpdater.mjs
Normal file
47
app/data/updaters/XRankUpdater.mjs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import prefixedConsole from "../../common/prefixedConsole.mjs";
|
||||
import DataUpdater from "./DataUpdater.mjs";
|
||||
import XRankDetailUpdater from "./XRankDetailUpdater.mjs";
|
||||
|
||||
export default class XRankUpdater extends DataUpdater
|
||||
{
|
||||
name = 'X-Rank';
|
||||
filename = 'xrank/xrank';
|
||||
|
||||
imagePaths = [
|
||||
'$..image.url',
|
||||
'$..image2d.url',
|
||||
'$..image2dThumbnail.url',
|
||||
'$..image3d.url',
|
||||
'$..image3dThumbnail.url',
|
||||
];
|
||||
|
||||
constructor(divisionName, divisionKey) {
|
||||
super();
|
||||
|
||||
this.divisionName = divisionName;
|
||||
this.divisionKey = divisionKey;
|
||||
this.filename += `.${divisionName.toLowerCase()}`;
|
||||
}
|
||||
|
||||
get console() {
|
||||
this._console ??= prefixedConsole('Updater', this.region, this.name, this.divisionName);
|
||||
|
||||
return this._console;
|
||||
}
|
||||
|
||||
async getData(locale) {
|
||||
let result = await this.splatnet(locale).getXRankingData(this.divisionKey);
|
||||
|
||||
let seasonId = result.data.xRanking.currentSeason.id;
|
||||
await this.updateSeasonDetail(seasonId);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async updateSeasonDetail(seasonId) {
|
||||
for (let type of this.splatnet().getXRankingDetailQueryTypes()) {
|
||||
let updater = new XRankDetailUpdater(seasonId, type);
|
||||
await updater.updateIfNeeded();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -147,4 +147,77 @@ export default class SplatNet3Client
|
|||
getCurrentFestData() {
|
||||
return this.getGraphQLPersistedQuery(1, 'c0429fd738d829445e994d3370999764');
|
||||
}
|
||||
|
||||
getXRankingData(region) {
|
||||
return this.getGraphQLPersistedQuery(1, 'd771444f2584d938db8d10055599011d', { region });
|
||||
}
|
||||
|
||||
getXRankingDetailQueryTypes() {
|
||||
return [
|
||||
{
|
||||
name: 'Splat Zones Leaderboard',
|
||||
key: 'splatzones',
|
||||
id: 'eb69df6f2a2f13ab207eedc568f0f8b6',
|
||||
dataKey: 'xRankingAr',
|
||||
},
|
||||
{
|
||||
name: 'Splat Zones Top Weapons',
|
||||
key: 'splatzones.weapons',
|
||||
id: 'a6782a0c692e8076656f9b4ab613fd82',
|
||||
dataKey: 'weaponTopsAr',
|
||||
},
|
||||
{
|
||||
name: 'Clam Blitz Leaderboard',
|
||||
key: 'clamblitz',
|
||||
id: '68f99b7b02537bcb881db07e4e67f8dd',
|
||||
dataKey: 'xRankingCl',
|
||||
},
|
||||
{
|
||||
name: 'Clam Blitz Top Weapons',
|
||||
key: 'clamblitz.weapons',
|
||||
id: '8d3c5bb2e82d6eb32a37eefb0e1f8f69',
|
||||
dataKey: 'weaponTopsCl',
|
||||
},
|
||||
{
|
||||
name: 'Rainmaker Leaderboard',
|
||||
key: 'rainmaker',
|
||||
id: '5f8f333770ed3c43e21b0121f3a86716',
|
||||
dataKey: 'xRankingGl',
|
||||
},
|
||||
{
|
||||
name: 'Rainmaker Top Weapons',
|
||||
key: 'rainmaker.weapons',
|
||||
id: 'b23468857c049c2f0684797e45fabac1',
|
||||
dataKey: 'weaponTopsGl',
|
||||
},
|
||||
{
|
||||
name: 'Tower Control Leaderboard',
|
||||
key: 'towercontrol',
|
||||
id: '4e8b381ae6f9620443627f4eac3a2210',
|
||||
dataKey: 'xRankingLf',
|
||||
},
|
||||
{
|
||||
name: 'Tower Control Top Weapons',
|
||||
key: 'towercontrol.weapons',
|
||||
id: 'd46f88c2ea5c4daeb5fe9d5813d07a99',
|
||||
dataKey: 'weaponTopsLf',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getXRankingDetail(type, id, page = 1) {
|
||||
// The API splits this data into 5 pages of 100 results (param: "page").
|
||||
// Each page is segmented into smaller 25-record chunks (by default) as well (param: "first").
|
||||
// We can just pass a larger number (up to 100) into the "first" param
|
||||
// to retrieve all results for that page.
|
||||
let first = 100;
|
||||
|
||||
return this.getGraphQLPersistedQuery(1, type.id, { id, first, page });
|
||||
}
|
||||
|
||||
async *getXRankingDetailPages(type, id) {
|
||||
for (let page = 1; page <= 5; page++) {
|
||||
yield await this.getXRankingDetail(type, id, page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user