mirror of
https://github.com/smogon/pokemon-showdown-loginserver.git
synced 2026-04-26 01:31:42 -05:00
Serve count of IPs as well
This commit is contained in:
parent
c8aed44d69
commit
76394e23b6
|
|
@ -187,7 +187,7 @@ exports.standings = {
|
|||
};
|
||||
|
||||
/**
|
||||
* @type {null | ((userid: string) => Promise<{[k: string]: {min: number, max: number}}>)}
|
||||
* Get IPs (Map<ip, timestamp used>) of a given userid.
|
||||
* @type {null | ((userid: string) => Promise<{[k: string]: {min: number, max: number, count: number}}>)}
|
||||
* Get IPs of a given userid.
|
||||
*/
|
||||
exports.getuserips = null;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ export function escapeHTML(str: string | number) {
|
|||
}
|
||||
|
||||
export class TimeSorter {
|
||||
private data: Record<string, {min: number, max: number}> = {};
|
||||
private data: Record<string, {min: number, max: number, count: number}> = {};
|
||||
add(key: string, timestamp: number) {
|
||||
if (this.data[key]) {
|
||||
if (this.data[key].min > timestamp) {
|
||||
|
|
@ -115,11 +115,12 @@ export class TimeSorter {
|
|||
if (timestamp > this.data[key].max) {
|
||||
this.data[key].max = timestamp;
|
||||
}
|
||||
this.data[key].count++;
|
||||
} else {
|
||||
this.data[key] = {min: timestamp, max: timestamp};
|
||||
this.data[key] = {min: timestamp, max: timestamp, count: 1};
|
||||
}
|
||||
}
|
||||
toJSON() {
|
||||
toJSON(): TimeSorter['data'] {
|
||||
return this.data;
|
||||
}
|
||||
merge(other: TimeSorter | TimeSorter['data']) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user