Created
September 13, 2018 15:43
-
-
Save Lodo4ka/3c7a93d5b7ad0fb8fac418358a5a33f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it.only("create cache file", () => { | |
let cacheResult = {}; | |
const query3 = "SELECT * FROM profile_systems"; | |
const newCursor = client.query(new Cursor(query3)); | |
newCursor.read(20, (err, rowsTop) => { | |
if (err) { | |
throw err; | |
} | |
test(err => { | |
try { | |
rowsTop.forEach((block, index) => { | |
cacheResult[block.id] = {}; | |
const query4 = `SELECT * FROM profile_systems INNER JOIN lists | |
ON profile_systems.rama_list_id=lists.id WHERE profile_systems.id=${block.id}`; | |
const againNewCursor = client.query(new Cursor(query4)); | |
againNewCursor.read(20, (err, rows) => { | |
if (err) { | |
throw err; | |
} | |
console.log("1"); | |
cacheResult[block.id].frameDepth = { | |
a: rows[0].a, | |
b: rows[0].b, | |
c: rows[0].c, | |
d: rows[0].d}; | |
againNewCursor.close(() => { | |
}); | |
}); | |
const query5 = `SELECT * FROM profile_systems INNER JOIN lists | |
ON profile_systems.rama_still_list_id=lists.id WHERE profile_systems.id=${block.id}`; | |
const again2NewCursor = client.query(new Cursor(query5)); | |
again2NewCursor.read(20, (err, rows) => { | |
if (err) { | |
throw err; | |
} | |
console.log("2"); | |
cacheResult[block.id].frameStillDepth = { | |
a: rows[0].a, | |
b: rows[0].b, | |
c: rows[0].c, | |
d: rows[0].d}; | |
again2NewCursor.close(() => { | |
}); | |
}); | |
const query6 = `SELECT * FROM profile_systems INNER JOIN lists | |
ON profile_systems.stvorka_list_id=lists.id WHERE profile_systems.id=${block.id}`; | |
const again3NewCursor = client.query(new Cursor(query6)); | |
again3NewCursor.read(20, (err, rows) => { | |
if (err) { | |
throw err; | |
} | |
console.log("3"); | |
cacheResult[block.id].sashDepth = { | |
a: rows[0].a, | |
b: rows[0].b, | |
c: rows[0].c, | |
d: rows[0].d}; | |
again3NewCursor.close(() => { | |
}); | |
}); | |
const query7 = `SELECT * FROM profile_systems INNER JOIN lists | |
ON profile_systems.impost_list_id=lists.id WHERE profile_systems.id=${block.id}`; | |
const again4NewCursor = client.query(new Cursor(query7)); | |
again4NewCursor.read(20, (err, rows) => { | |
if (err) { | |
throw err; | |
} | |
console.log("4"); | |
cacheResult[block.id].impostDepth = { | |
a: rows[0].a, | |
b: rows[0].b, | |
c: rows[0].c, | |
d: rows[0].d}; | |
again4NewCursor.close(() => { | |
}); | |
}); | |
const query8 = `SELECT * FROM profile_systems INNER JOIN lists | |
ON profile_systems.shtulp_list_id=lists.id WHERE profile_systems.id=${block.id}`; | |
const again5NewCursor = client.query(new Cursor(query8)); | |
again5NewCursor.read(20, (err, rows) => { | |
if (err) { | |
throw err; | |
} | |
console.log("5"); | |
cacheResult[block.id].shtulpDepth = { | |
a: rows[0].a, | |
b: rows[0].b, | |
c: rows[0].c, | |
d: rows[0].d}; | |
again5NewCursor.close(() => { | |
}); | |
if(index === rowsTop.length - 1) { | |
console.log("yes"); | |
fs.writeFile("./depths.json", JSON.stringify(cacheResult), function (err) { | |
if(err) { | |
throw err; | |
} | |
}); | |
} | |
}); | |
}); | |
} | |
catch (e) { | |
console.error(e); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment