Skip to content

Instantly share code, notes, and snippets.

@ermst4r
Created April 19, 2018 14:14
Show Gist options
  • Save ermst4r/8b29bf8b63d74f639521e04c4481dabb to your computer and use it in GitHub Desktop.
Save ermst4r/8b29bf8b63d74f639521e04c4481dabb to your computer and use it in GitHub Desktop.
Promises
UserProfileMatch.getNewUser(item.fk_user_id).then(function (user) {
ActiveAuctionProfile.closeActiveAuctionProfile(item.aap_id).then(function () {
if(user.length > 0 ) {
ActiveAuctionProfile.isProfileActive(user[0].profile_id).then(function (is_active) {
UserProfileMatch.countActiveProfilesForUser(item.fk_user_id).then(function (number_of_profiles) {
if(is_active.result === 0 && number_of_profiles < config.settings.lovingbids_start_profile) {
UserProfileMatch.updateProfileMatch(item.fk_user_id, user[0].profile_id,1,false).then(function () {
ActiveAuctionProfile.createNewActiveProfile({
fk_auction_profile_id:user[0].profile_id,
start_date:moment().format("YYYY-MM-DD HH:mm:ss") ,
expire_date:moment().add(config.settings.increment_settings,'seconds').format("YYYY-MM-DD HH:mm:ss")
}).then(function () {
ExpireProfileRegister.removeExpireResult(item.id);
page++;
next();
});
})
} else {
console.log("exists");
ExpireProfileRegister.removeExpireResult(item.id);
page++;
next();
}
});
});
} else {
console.log("niet");
page++;
next();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment