Commit 59c40a1f authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent eadbcf9d
......@@ -7,22 +7,18 @@ let alocatedReserve = 3
let alocatedReserveCompound = 3
work()
async function work()
{
async function work() {
let directory = await fs.readdirSync('result')
for (let i=0;i<directory.length ;i=i+1000)
{
console.log('hi')
let arr=[]
for (let j=0;j<1000;j++)
{
for (let i = 0; i < directory.length; i = i + 1000) {
// console.log('hi')
let arr = []
for (let j = 0; j < 1000; j++) {
try {
arr.push(directory[j+i])
}
catch (e)
{
if ((j + i) < directory.length)
arr.push(directory[j + i])
} catch (e) {
}
......@@ -30,37 +26,36 @@ async function work()
}
if (arr.length !==0)
{
if (arr.length !== 0) {
let timestamp = Date.now()
try {
await fs.mkdirSync('last1000/' + timestamp)
} catch (e) {
}
run('profitPerMonth1000',arr,timestamp)
run('percentage1000',arr,timestamp)
run('compound1000',arr,timestamp)
run('allocatedReservePerMonthUnder3',arr,timestamp)
run('allocatedReserveCompoundUnder3',arr,timestamp)
run('allocatedReservePerMonthUnder2',arr,timestamp)
await run('allocatedReserveCompoundUnder2',arr,timestamp)
run('profitPerMonth1000', arr, timestamp)
run('percentage1000', arr, timestamp)
run('compound1000', arr, timestamp)
run('allocatedReservePerMonthUnder3', arr, timestamp)
run('allocatedReserveCompoundUnder3', arr, timestamp)
run('allocatedReservePerMonthUnder2', arr, timestamp)
await run('allocatedReserveCompoundUnder2', arr, timestamp)
}
}
}
async function run(name,directory,timestamp) {
async function run(name, directory, timestamp) {
// let directory = await fs.readdirSync('result')
let arr2 = []
let arrFinal = []
let last = []
for (let f = 0; f < directory.length; f++)
{
if (typeof directory[f] ==="undefined")
console.log(directory)
for (let f = 0; f < directory.length; f++) {
if (typeof directory[f] === "undefined")
continue
console.log(directory[f])
arrFinal.push(readFile(name, directory[f]))
}
......@@ -115,9 +110,9 @@ async function run(name,directory,timestamp) {
las.push(last[i])
createfileADV(timestamp,name, JSON.stringify(las, null, 2))
createfileADV(timestamp, name, JSON.stringify(las, null, 2))
last=[]
last = []
}
......@@ -148,9 +143,9 @@ async function readFile(name, directory) {
return file
}
function createfileADV(timestamp,filename, data) {
function createfileADV(timestamp, filename, data) {
return new Promise(function (resolve, reject) {
fs.writeFile('last1000/' +timestamp+'/'+ filename + '.json', data, 'utf8', function (err) {
fs.writeFile('last1000/' + timestamp + '/' + filename + '.json', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment