fix: RankTracker broken when token expires
parent
82c82bed94
commit
af941a59fd
|
|
@ -1,3 +1,7 @@
|
||||||
|
## 0.1.16
|
||||||
|
|
||||||
|
fix: RankTracker broken when token expires
|
||||||
|
|
||||||
## 0.1.15
|
## 0.1.15
|
||||||
|
|
||||||
fix: rank point change is not uploaded at first challenge ([#11](https://github.com/spacemeowx2/s3si.ts/issues/11))
|
fix: rank point change is not uploaded at first challenge ([#11](https://github.com/spacemeowx2/s3si.ts/issues/11))
|
||||||
|
|
|
||||||
63
src/app.ts
63
src/app.ts
|
|
@ -129,28 +129,7 @@ export class App {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
async exportOnce() {
|
async exportOnce() {
|
||||||
const exporters = await this.getExporters();
|
await retryRecoverableError(() => this._exportOnce(), this.recoveryToken);
|
||||||
const stats: Record<string, number> = Object.fromEntries(
|
|
||||||
exporters.map((e) => [e.name, 0]),
|
|
||||||
);
|
|
||||||
|
|
||||||
await retryRecoverableError(() =>
|
|
||||||
this._exportOnce({
|
|
||||||
stats,
|
|
||||||
}), {
|
|
||||||
...this.recoveryToken,
|
|
||||||
recovery: () => {
|
|
||||||
if (Object.values(stats).some((i) => i > 0)) {
|
|
||||||
printStats(stats);
|
|
||||||
for (const key of Object.keys(stats)) {
|
|
||||||
stats[key] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.recoveryToken.recovery();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
printStats(stats);
|
|
||||||
}
|
}
|
||||||
exporterProgress(title: string) {
|
exporterProgress(title: string) {
|
||||||
const bar = !this.opts.noProgress
|
const bar = !this.opts.noProgress
|
||||||
|
|
@ -172,7 +151,9 @@ export class App {
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
} else if (progress.currentUrl) {
|
} else if (progress.currentUrl) {
|
||||||
console.log(`Battle uploaded to ${progress.currentUrl}`);
|
console.log(
|
||||||
|
`Battle exported to ${progress.currentUrl} (${progress.current}/${progress.total})`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const endBar = () => {
|
const endBar = () => {
|
||||||
|
|
@ -181,13 +162,15 @@ export class App {
|
||||||
|
|
||||||
return { redraw, endBar };
|
return { redraw, endBar };
|
||||||
}
|
}
|
||||||
private async _exportOnce(
|
private async _exportOnce() {
|
||||||
{ stats }: {
|
|
||||||
stats: Record<string, number>;
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
const exporters = await this.getExporters();
|
const exporters = await this.getExporters();
|
||||||
|
const initStats = () =>
|
||||||
|
Object.fromEntries(
|
||||||
|
exporters.map((e) => [e.name, 0]),
|
||||||
|
);
|
||||||
|
let stats = initStats();
|
||||||
const skipMode = this.getSkipMode();
|
const skipMode = this.getSkipMode();
|
||||||
|
const errors: unknown[] = [];
|
||||||
|
|
||||||
if (skipMode.includes("vs")) {
|
if (skipMode.includes("vs")) {
|
||||||
console.log("Skip exporting VS games.");
|
console.log("Skip exporting VS games.");
|
||||||
|
|
@ -211,18 +194,27 @@ export class App {
|
||||||
fetcher,
|
fetcher,
|
||||||
exporter: e,
|
exporter: e,
|
||||||
gameList,
|
gameList,
|
||||||
onStep: (progress) => redraw(e.name, progress),
|
onStep: (progress) => {
|
||||||
|
redraw(e.name, progress);
|
||||||
|
stats[e.name] = progress.current;
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.then((count) => {
|
.then((count) => {
|
||||||
stats[e.name] = count;
|
stats[e.name] = count;
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
errors.push(err);
|
||||||
console.error(`\nFailed to export to ${e.name}:`, err);
|
console.error(`\nFailed to export to ${e.name}:`, err);
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
printStats(stats);
|
||||||
|
if (errors.length > 0) {
|
||||||
|
throw errors[0];
|
||||||
|
}
|
||||||
|
|
||||||
// save rankState only if all exporters succeeded
|
// save rankState only if all exporters succeeded
|
||||||
fetcher.setRankState(finalRankState);
|
fetcher.setRankState(finalRankState);
|
||||||
await this.writeState({
|
await this.writeState({
|
||||||
|
|
@ -233,6 +225,8 @@ export class App {
|
||||||
endBar();
|
endBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stats = initStats();
|
||||||
|
|
||||||
// TODO: remove this filter when stat.ink support coop export
|
// TODO: remove this filter when stat.ink support coop export
|
||||||
const coopExporter = exporters.filter((e) => e.name !== "stat.ink");
|
const coopExporter = exporters.filter((e) => e.name !== "stat.ink");
|
||||||
if (skipMode.includes("coop") || coopExporter.length === 0) {
|
if (skipMode.includes("coop") || coopExporter.length === 0) {
|
||||||
|
|
@ -258,18 +252,27 @@ export class App {
|
||||||
fetcher,
|
fetcher,
|
||||||
exporter: e,
|
exporter: e,
|
||||||
gameList: coopBattleList,
|
gameList: coopBattleList,
|
||||||
onStep: (progress) => redraw(e.name, progress),
|
onStep: (progress) => {
|
||||||
|
stats[e.name] = progress.current;
|
||||||
|
redraw(e.name, progress);
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.then((count) => {
|
.then((count) => {
|
||||||
stats[e.name] = count;
|
stats[e.name] = count;
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
errors.push(err);
|
||||||
console.error(`\nFailed to export to ${e.name}:`, err);
|
console.error(`\nFailed to export to ${e.name}:`, err);
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
printStats(stats);
|
||||||
|
if (errors.length > 0) {
|
||||||
|
throw errors[0];
|
||||||
|
}
|
||||||
|
|
||||||
endBar();
|
endBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { StatInkPostBody, VsHistoryDetail } from "./types.ts";
|
import type { StatInkPostBody, VsHistoryDetail } from "./types.ts";
|
||||||
|
|
||||||
export const AGENT_NAME = "s3si.ts";
|
export const AGENT_NAME = "s3si.ts";
|
||||||
export const S3SI_VERSION = "0.1.15";
|
export const S3SI_VERSION = "0.1.16";
|
||||||
export const NSOAPP_VERSION = "2.3.1";
|
export const NSOAPP_VERSION = "2.3.1";
|
||||||
export const WEB_VIEW_VERSION = "1.0.0-5644e7a2";
|
export const WEB_VIEW_VERSION = "1.0.0-5644e7a2";
|
||||||
export const S3SI_LINK = "https://github.com/spacemeowx2/s3si.ts";
|
export const S3SI_LINK = "https://github.com/spacemeowx2/s3si.ts";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue