Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
9 changes: 8 additions & 1 deletion src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,14 @@ export const actions: {[k: string]: QueryHandler} = {
}
return {password: pw};
},

async 'replays/batch'(params) {
if (!params.ids) {
throw new ActionError("Invalid batch replay request, must provide ids");
}
const ids = params.ids.split(',');
if (ids.length > 51) throw new ActionError(`Limit 51 IDs (you have ${ids.length}).`);
return Replays.getBatch(ids);
},
// sent by ps server
async 'smogon/validate'(params) {
if (this.getIp() !== Config.restartip) {
Expand Down
4 changes: 4 additions & 0 deletions src/replays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ export const Replays = new class {
SQL`uploadtime, id, format, players, rating`
)`WHERE private = 0 ORDER BY uploadtime DESC LIMIT 51`.then(this.toReplays);
}

Comment thread
Zarel marked this conversation as resolved.
Outdated
getBatch(ids: string[]) {
return replays.selectAll()`WHERE private = 0 AND id IN (${ids}) LIMIT 51`.then(this.toReplays);
}
Comment thread
Zarel marked this conversation as resolved.
Outdated
};

export default Replays;