Commit eadbcf9d authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 684893b0
......@@ -5,21 +5,65 @@ let _ = require('lodash')
let sort = 'profitPerMonth'
let alocatedReserve = 3
let alocatedReserveCompound = 3
run('profitPerMonth1000')
run('percentage1000')
run('compound1000')
run('allocatedReservePerMonthUnder3')
run('allocatedReserveCompoundUnder3')
run('allocatedReservePerMonthUnder2')
run('allocatedReserveCompoundUnder2')
async function run(name) {
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++)
{
try {
arr.push(directory[j+i])
}
catch (e)
{
}
}
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)
}
}
}
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")
continue
arrFinal.push(readFile(name, directory[f]))
}
arrFinal = await Promise.all(arrFinal)
......@@ -71,9 +115,9 @@ async function run(name) {
las.push(last[i])
createfileADV(name, JSON.stringify(las, null, 2))
createfileADV(timestamp,name, JSON.stringify(las, null, 2))
last=[]
}
......@@ -104,9 +148,9 @@ async function readFile(name, directory) {
return file
}
function createfileADV(filename, data) {
function createfileADV(timestamp,filename, data) {
return new Promise(function (resolve, reject) {
fs.writeFile('final/' + 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