Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function stats() {
- return mongoose.models.Account
- .find()
- .then((accounts) => {
- const pilotEmails = pilotUsers.map(p => p.Email);
- const activeAccounts = accounts.filter(a => a.active).map(a => a.email);
- const inactiveAccounts = accounts.filter(a => !a.active).map(a => a.email);
- const activePilots = _.intersection(activeAccounts, pilotEmails).length;
- const inactivePilots = _.intersection(inactiveAccounts, pilotEmails).length;
- const activeRegular = activeAccounts.length - activePilots;
- const inactiveRegular = inactiveAccounts.length - inactivePilots;
- return Promise.resolve({
- totalUsers: accounts.length,
- regular: {
- active: activeRegular,
- inactive: inactiveRegular,
- },
- pilots: {
- active: activePilots,
- inactive: inactivePilots,
- },
- });
- })
- .catch((err) => {
- console.error(err);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement