<commit_before>Meteor.methods({
  'getResidentsLatestActivityByType': function (activityTypeId) {
    // Get resident latest activity by type
    var residentLatestActivityByType = Activities.aggregate([
      {$match:
        {activityTypeId: 'ccuz85YWbfAx4Yg7B'}
      },
      {$sort:
        {activityDate: -1}
      },
      {$unwind: '$residentIds'},
      {$group:
        {
          _id: "$residentIds",
          activityDate: {$first: '$activityDate'}
        }
      }
    ]);

    return residentLatestActivityByType;
  },
  'getResidentsNameHomeAndLatestActivityByType': function (activityTypeId) {
    // Create placeholder array for resident names with latest activity
    var residentNamesWithLatestActivity = [];

    // Get resident latest activity by type
    var latestActivities = Meteor.call('getResidentsLatestActivityByType', activityTypeId);

    // Set up array of residents with name, home, and activity fields
    latestActivities.forEach(function (latestActivity) {
      // Get the resident ID
      var residentId = latestActivity._id;

      // Get resident from collection
      var resident = Residents.findOne(residentId);

      // Construct object containing resident name, home name, and last activity date
      var residentNameAndLatestActivity = {
        residentName: resident.fullName(),
        homeName: resident.homeName(),
        lastActivityDate: latestActivity.activityDate
      };

      residentNamesWithLatestActivity.push(residentNameAndLatestActivity);
    });

    return residentNamesWithLatestActivity;
  },
  'getResidentsWithoutActivityByType': function (activityTypeId) {
    // Get resident latest activity by type
    var residentLastActivityByType = Meteor.call('getResidentsLatestActivityByType', activityTypeId);

    // Get all resident IDs
    var residentIds = Residents.find({}, {fields: {_id: 1}}).fetch();

    // Get residents who have participated in the activity type
    var residentsWithPreviousActivity = _.map(residentLastActivityByType, function (resident) {<commit_msg>Use underscore map function instead of array forEach<commit_after>Meteor.methods({
  'getResidentsLatestActivityByType': function (activityTypeId) {
    // Get resident latest activity by type
    var residentLatestActivityByType = Activities.aggregate([
      {$match:
        {activityTypeId: 'ccuz85YWbfAx4Yg7B'}
      },
      {$sort:
        {activityDate: -1}
      },
      {$unwind: '$residentIds'},
      {$group:
        {
          _id: "$residentIds",
          activityDate: {$first: '$activityDate'}
        }
      }
    ]);

    return residentLatestActivityByType;
  },
  'getResidentsNameHomeAndLatestActivityByType': function (activityTypeId) {
    // Create placeholder array for resident names with latest activity
    var residentNamesWithLatestActivity = [];

    // Get resident latest activity by type
    var latestActivities = Meteor.call('getResidentsLatestActivityByType', activityTypeId);

    // Set up array of residents with name, home, and activity fields
    var residentNamesWithLatestActivity = _.map(latestActivities, function (latestActivity) {
      // Get the resident ID
      var residentId = latestActivity._id;

      // Get resident from collection
      var resident = Residents.findOne(residentId);

      // Construct object containing resident name, home name, and last activity date
      var residentNameAndLatestActivity = {
        residentName: resident.fullName(),
        homeName: resident.homeName(),
        lastActivityDate: latestActivity.activityDate
      };

      return residentNameAndLatestActivity;
    });

    return residentNamesWithLatestActivity;
  },
  'getResidentsWithoutActivityByType': function (activityTypeId) {
    // Get resident latest activity by type
    var residentLastActivityByType = Meteor.call('getResidentsLatestActivityByType', activityTypeId);

    // Get all resident IDs
    var residentIds = Residents.find({}, {fields: {_id: 1}}).fetch();

    // Get residents who have participated in the activity type
    var residentsWithPreviousActivity = _.map(residentLastActivityByType, function (resident) {
{'fraction_non_alphanumeric': 0.08985786557456035, 'fraction_numerical': 0.002890869669959046, 'mean_word_length': 3.3983050847457625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7192056', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1060, 'n_words': 289}