feat: Create and use dynamic active donation counts
This commit is contained in:
committed by
mrugesh mohapatra
parent
331ea3ebf9
commit
8fab33ba99
@ -2,14 +2,18 @@ import { Observable } from 'rx';
|
||||
|
||||
export default function(Donation) {
|
||||
Donation.on('dataSourceAttached', () => {
|
||||
Donation.find$ = Observable.fromNodeCallback(Donation.find.bind(Donation));
|
||||
Donation.findOne$ = Observable.fromNodeCallback(
|
||||
Donation.findOne.bind(Donation)
|
||||
);
|
||||
Donation.prototype.validate$ = Observable.fromNodeCallback(
|
||||
Donation.prototype.validate
|
||||
);
|
||||
Donation.prototype.destroy$ = Observable.fromNodeCallback(
|
||||
Donation.prototype.destroy
|
||||
);
|
||||
});
|
||||
|
||||
function getCurrentActiveDonationCount$() {
|
||||
// eslint-disable-next-line no-undefined
|
||||
return Donation.find$({ where: { endDate: undefined } }).map(
|
||||
instances => instances.length
|
||||
);
|
||||
}
|
||||
|
||||
Donation.getCurrentActiveDonationCount$ = getCurrentActiveDonationCount$;
|
||||
}
|
||||
|
Reference in New Issue
Block a user