<commit_before>var Promise = require('bluebird');

module.exports = {

  changedCommunities: function(startTime, endTime) {

    return Promise.join(
      // new members
      User.createdInTimeRange(startTime, endTime).fetchAll({withRelated: ['memberships']}),

      // new posts
      Post.createdInTimeRange(startTime, endTime)
      .query(qb => qb.where('post.type', '!=', 'welcome'))
      .fetchAll({withRelated: [
        {communities: qb => qb.column('community_id')}
      ]}),

      // new comments
      Comment.createdInTimeRange(startTime, endTime)
      .query(qb => {
        qb.join('post', () => this.on('post.id', 'comment.post_id'));
        qb.where('post.type', '!=', 'welcome');
      })
      .fetchAll({withRelated: [
        {post: qb => qb.column('id')},
        {'post.communities': qb => qb.column('community_id')}
      ]})
    ).spread(function(users, posts, comments) {

      var communityIds = [];

      users.each(function(u) {
        var ids = u.relations.memberships.map(m => m.get('community_id'));
        communityIds.push(ids);
      });

      posts.each(function(s) {
        var ids = s.relations.communities.map('id');
        communityIds.push(ids);
      });

      comments.each(function(c) {
        var ids = c.relations.post.relations.communities.map('community_id');
        communityIds.push(ids);
      });

      return _.union.apply(_, communityIds).sort((a, b) => a > b);
    });

  }

};
<commit_msg>fix the use of community id in changes.js<commit_after>var Promise = require('bluebird');

module.exports = {

  changedCommunities: function(startTime, endTime) {

    return Promise.join(
      // new members
      User.createdInTimeRange(startTime, endTime).fetchAll({withRelated: ['memberships']}),

      // new posts
      Post.createdInTimeRange(startTime, endTime)
      .query(qb => qb.where('post.type', '!=', 'welcome'))
      .fetchAll({withRelated: [
        {communities: qb => qb.column('community.id')}
      ]}),

      // new comments
      Comment.createdInTimeRange(startTime, endTime)
      .query(qb => {
        qb.join('post', () => this.on('post.id', 'comment.post_id'));
        qb.where('post.type', '!=', 'welcome');
      })
      .fetchAll({withRelated: [
        {post: qb => qb.column('id')},
        {'post.communities': qb => qb.column('community.id')}
      ]})
    ).spread(function(users, posts, comments) {

      var communityIds = [];

      users.each(function(u) {
        var ids = u.relations.memberships.map(m => m.get('community_id'));
        communityIds.push(ids);
      });

      posts.each(function(s) {
        var ids = s.relations.communities.map('id');
        communityIds.push(ids);
      });

      comments.each(function(c) {
        var ids = c.relations.post.relations.communities.map('id');
        communityIds.push(ids);
      });

      return _.union.apply(_, communityIds).sort((a, b) => a > b);
    });

  }

};

{'fraction_non_alphanumeric': 0.18036684782608695, 'fraction_numerical': 0.0, 'mean_word_length': 2.6223862238622386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '6240386', 'n_tokens_mistral': 987, 'n_tokens_neox': 937, 'n_words': 145}