mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-08-23 00:54:21 -05:00
Add X-Rank leaderboard data
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user