Skip to content

Instantly share code, notes, and snippets.

@digitalsadhu
Created September 16, 2015 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalsadhu/792a789283f5c577b000 to your computer and use it in GitHub Desktop.
Save digitalsadhu/792a789283f5c577b000 to your computer and use it in GitHub Desktop.
var findContract = _.flip(_.wrapCallback(Contract.findById.bind(Contract)), {remoteCtx: ctx});
var findContractPeriods = _.flip(_.wrapCallback(ContractPeriod.find.bind(ContractPeriod)), {remoteCtx: ctx});
var findContractPeriod = _.flip(_.wrapCallback(ContractPeriod.findById.bind(ContractPeriod)), {remoteCtx: ctx});
var findReviews = _.flip(_.wrapCallback(Review.find.bind(Review)), {remoteCtx: ctx});
var sendEmail = _.wrapCallback(sendReminderEmail);
var contractPeriodStream1 = findReviews(query).flatten().pluck('contractPeriodId').map(findContractPeriod);
var contractPeriodStream2 = findContractPeriods(query).flatten();
contractPeriodStream1.merge(contractPeriodStream2)
.pluck('contractId').uniq()
.map(findContract).flatten()
.map(sendEmail).flatten()
.errors(cb)
.done(cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment