new code fix
This commit is contained in:
@@ -30,32 +30,26 @@ MongoClient.connect(config.databaseURL).then(mongoDatabase => {
|
||||
let getDomainListPromises = [];
|
||||
|
||||
config.domainList.map(url=>{
|
||||
let p = links.getDomainList(url).then(res=>{
|
||||
console.log("One promise done");
|
||||
let p2 = database.insertTodayDomains(db,res).then(()=>{
|
||||
let p3 = database.getYesterdayDomains(db).then((result)=>{
|
||||
getDomainListPromises.push(links.getDomainList(url).then(res=>{
|
||||
return database.insertTodayDomains(db,res);
|
||||
}).then(()=>{
|
||||
return database.getYesterdayDomains(db);
|
||||
}).then(result=>{
|
||||
return database.insertExpired(db,result);
|
||||
}).catch(e=>{
|
||||
console.log("Err : " +e);
|
||||
}));
|
||||
|
||||
result.map((domain)=>{
|
||||
getDomainListPromises.push(database.cleanExpired(db,domain));
|
||||
});
|
||||
|
||||
}).catch((e)=>{
|
||||
console.log(e);
|
||||
});
|
||||
getDomainListPromises.push(p3);
|
||||
});
|
||||
getDomainListPromises.push(p2);
|
||||
});
|
||||
getDomainListPromises.push(p);
|
||||
});
|
||||
|
||||
Promise.all(getDomainListPromises).then(()=>{
|
||||
console.log("All promises done");
|
||||
database.getExpiredDomains(db).then((result)=>{
|
||||
links.checkExpiredDomains(db,result).then(()=>{
|
||||
db.close();
|
||||
});
|
||||
database.getExpiredDomains(db).then(result=>{
|
||||
return links.checkExpiredDomains(db,result);
|
||||
}).then(()=>{
|
||||
console.log("Done - closing");
|
||||
db.close();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user