hypixel-auction-notifier/src/sqlConsoleCommands.ts
2024-12-30 16:14:37 +02:00

52 lines
1.5 KiB
TypeScript

import { SqlSystem } from './sqlFunctions';
class SqlCommands {
private static async InsertDummyData() {
console.log("Inserting random numbers into Pool");
let dummy_auctionid: string[] = this.randomArray(10,8),dummy_lbin: number[] = this.randomArray(10,5);
await SqlSystem.Upsert(dummy_auctionid,dummy_lbin)
}
private static async RequestDummyData() {
console.log("Requesting All from table auctions");
console.log(await SqlSystem.Query("SELECT * FROM auctions"));
}
public static async main(): Promise<void> {
const command_args = process.argv.slice(2);
if(arguments.length===0) return;
switch(command_args[0].toString()) {
case "insdummy": {
this.InsertDummyData();
break;
}
case "reqdummy": {
this.RequestDummyData();
break;
}
default:break;
}
}
private static randomArray(item_count: number,range_scale: number): any {
let random_array: any[] = [];
for(let i: number = 0;i<item_count;i++)
{
random_array.push(this.randomNumber(range_scale));
}
return random_array;
}
private static randomNumber(range_scale: number): number {
return Math.floor(Math.random() * (Math.pow(10, range_scale) - Math.pow(10, range_scale - 1))) + Math.pow(10, range_scale - 1);
}
//example
// scale 1 returns a number from 0 to 9
// scale 2 returns a number from 10 to 99
// scale 3 returns a number from 100 to 999
// ...
// scale 64 returns a crash
}
SqlCommands.main();