imports/vx/server/reporter/reporter.js
/**
     * For a given user, iterate through the reportPreferences collection finding scheduled reports that
     * need to be created.  Based on the previous search, there should be at least one.
     *
     * @param {object} user User record.
     */
For a given user, iterate through the reportPreferences collection finding scheduled reports that
need to be created.  Based on the previous search, there should be at least one.

@param {object} user User record.
For a given user iterate through the reportPreferences collection finding scheduled reports that need to be created . Based on the previous search there should be at least one . @param { object } user User record .
createScheduledReports(user) {
        user.profile.reportPreferences.forEach((reportPreference, index) => {
            try {
                if (reportPreference.nextDate > new Date()) {
                    return
                }
                const reportParameterDefaults = Util.reportParameterDefaults(reportPreference.reportType, user._id)
                const result = Reporter.sendReport(user._id, reportPreference.reportType, reportParameterDefaults)
                if (!result.success) {
                    return
                }
                const nextDate = Util.computeNextDate(reportPreference.reportFrequency, reportPreference.timeUnit,
                    reportPreference.timeOption, user.profile.timezone, reportPreference.nextDate)
                const $set = {}
                $set[`profile.reportPreferences.${index}.lastDate`] = reportPreference.nextDate
                $set[`profile.reportPreferences.${index}.nextDate`] = nextDate
                OLog.debug("reporter.js createScheduledReports send completed, updating profile " +
                    `email=${Util.getUserEmail(user._id)} $set=${OLog.debugString($set)}`)
                Meteor.users.update( { _id: user._id }, { $set: $set } )
            }
            catch (error) {
                OLog.error("reporter.js createScheduledReports unexpected error=" + error)
                return
            }
        })
    }
createScheduledReports ( user ) { user . profile . reportPreferences . forEach ( ( reportPreference , index ) => { try { if ( reportPreference . nextDate > new Date ( ) ) { return } const reportParameterDefaults = Util . reportParameterDefaults ( reportPreference . reportType , user . _id ) const result = Reporter . sendReport ( user . _id , reportPreference . reportType , reportParameterDefaults ) if ( ! result . success ) { return } const nextDate = Util . computeNextDate ( reportPreference . reportFrequency , reportPreference . timeUnit , reportPreference . timeOption , user . profile . timezone , reportPreference . nextDate ) const $set = { } $set [ ` ${ index } ` ] = reportPreference . nextDate $set [ ` ${ index } ` ] = nextDate OLog . debug ( "reporter.js createScheduledReports send completed, updating profile " + ` ${ Util . getUserEmail ( user . _id ) } ${ OLog . debugString ( $set ) } ` ) Meteor . users . update ( { _id : user . _id } , { $set : $set } ) } catch ( error ) { OLog . error ( "reporter.js createScheduledReports unexpected error=" + error ) return } } ) }
For a given user, iterate through the reportPreferences collection finding scheduled reports that
 need to be created.
For a given user iterate through the reportPreferences collection finding scheduled reports that need to be created .