|
const makeUser = id => ({ |
|
_id: id, |
|
username: id, |
|
len: id.length, |
|
email: `${id}@user.com`, |
|
lang: "en-US", |
|
perfs: {}, |
|
count: { "ai" : 0, "draw" : 0, "drawH" : 0, "game" : 0, "loss" : 0, "lossH" : 0, "rated" : 0, "win" : 0, "winH" : 0 }, |
|
time: { "total": 0, "tv": 0 }, |
|
enabled: true, |
|
createdAt: ISODate("2021-01-01T00:00:00"), |
|
seenAt: ISODate("2021-01-01T00:00:00"), |
|
bpass: BinData(0,"5TSI+p3rOp8Yl6l2OsI8MXQiK/5XtmHJk79Qby9RVRQakiYE6Q52") // password is "asdfjkl;" |
|
}); |
|
|
|
// White wins |
|
const makeGame1 = (id, white, black) => ({ |
|
_id: id, |
|
is: 'xxxxyyyy', |
|
us: [white, black], |
|
p0: { e: 1500, p: true, l: 100 }, |
|
p1: { e: 1500, p: true, l: 100 }, |
|
s: NumberInt(30), |
|
t: 13, |
|
ca: ISODate('2021-04-01T00:00:00'), |
|
ua: ISODate('2021-04-01T00:00:00'), |
|
so: 2, |
|
hp: BinData(0, 'AlbtTYMA'), |
|
mt: BinData(0, 'VXRkRVVUcA=='), |
|
w: true, |
|
wid: white |
|
}); |
|
|
|
const makePuzzle1 = (id, gameId) => ({ |
|
_id: id, |
|
gameId: gameId, |
|
fen: 'r2qkbnr/ppp2ppp/2np4/4N3/2B1P1b1/2N5/PPPP1PPP/R1BQK2R b KQkq - 0 5', |
|
line: 'g4d1 c4f7 e8e7 c3d5', |
|
themes: ["mix"], |
|
glicko: { r: 1500, d: 50, v: 0.1 }, |
|
plays: 0, |
|
vote: 0, |
|
}); |
|
|
|
// Black wins |
|
const makeGame2 = (id, white, black) => ({ |
|
_id: id, |
|
is: 'xxxxyyyy', |
|
us: [white, black], |
|
p0: { e: 1500, p: true, l: 76.0 }, |
|
p1: { e: 1500, p: true, l: 25.0 }, |
|
s: NumberInt(30), |
|
t: 14, |
|
ca: ISODate('2021-03-10T13:46:44.299Z'), |
|
ua: ISODate('2021-03-10T13:47:32.954Z'), |
|
so: 2, |
|
hp: BinData(0, 'CGyq4pSUQA=='), |
|
mt: BinData(0, 'hWhUVmdERA=='), |
|
w: false, |
|
wid: black, |
|
}); |
|
|
|
const makePuzzle2 = (id, gameId) => ({ |
|
_id: id, |
|
gameId: gameId, |
|
fen: "r1bqk2r/pppp1ppp/2n5/2b1p1B1/4n3/2NP1P2/PPP3PP/R2QKBNR w KQkq - 0 6", |
|
line: "g5d8 c5f2 e1e2 c6d4", |
|
themes: ["mix"], |
|
glicko: { r: 1500, d: 50, v: 0.1 }, |
|
plays: 0, |
|
vote: 0, |
|
}); |
|
|
|
const user1 = 'u000'; |
|
const user2 = 'u001'; |
|
const game1 = 'g0000000'; |
|
const game2 = 'g0000001'; |
|
const puzzles = Array(500).fill().map((_, i) => 'p' + String(i).padStart(4, '0')); |
|
|
|
db.user4.insertMany([makeUser(user1), makeUser(user2)]); |
|
db.game5.insertMany([makeGame1(game1, user1, user2), makeGame2(game2, user1, user2)]); |
|
|
|
db.puzzle2_puzzle.insertMany(puzzles.slice( 0, 250).map(id => makePuzzle1(id, game1))); |
|
db.puzzle2_puzzle.insertMany(puzzles.slice(250, 500).map(id => makePuzzle2(id, game2))); |
|
|
|
db.puzzle2_path.insertMany(['all', 'good'].map(tier => ({ |
|
_id: `mix_${tier}_0100_9999_xxxx_0`, |
|
min: `mix_${tier}_0100`, |
|
max: `mix_${tier}_9999`, |
|
ids: puzzles, |
|
tier: tier, |
|
theme: 'mix', |
|
gen: 'xxxx' |
|
}))); |