<commit_before>var bcrypt = require('bcrypt')
var crypto = require('crypto')

module.exports = bookshelf.Model.extend({
  tableName: 'users',

  activity: function () {
    return this.hasMany(Activity, 'reader_id')
  },

  comments: function () {
    return this.hasMany(Comment)
  },

  communities: function () {
    return this.belongsToMany(Community, 'users_community')
  },

  contributions: function () {
    return this.hasMany(Contribution)
  },

  devices: function () {
    return this.hasMany(Device, 'user_id')
  },

  emails: function () {
    return this.hasMany(UserEmail)
  },

  followedPosts: function () {
    return this.belongsToMany(Post).through(Follow)
  },

  linkedAccounts: function () {
    return this.hasMany(LinkedAccount)
  },

  memberships: function () {
    return this.hasMany(Membership)
  },

  onboarding: function () {
    return this.hasOne(Tour).query({where: {type: 'onboarding'}})
  },

  organizations: function () {
    return this.hasMany(Organization)
  },

  phones: function () {
    return this.hasMany(UserPhone)
  },

  posts: function () {
    return this.hasMany(Post)
  },<commit_msg>don't include inactive memberships in user#memberships<commit_after>var bcrypt = require('bcrypt')
var crypto = require('crypto')

module.exports = bookshelf.Model.extend({
  tableName: 'users',

  activity: function () {
    return this.hasMany(Activity, 'reader_id')
  },

  comments: function () {
    return this.hasMany(Comment)
  },

  communities: function () {
    return this.belongsToMany(Community, 'users_community')
  },

  contributions: function () {
    return this.hasMany(Contribution)
  },

  devices: function () {
    return this.hasMany(Device, 'user_id')
  },

  emails: function () {
    return this.hasMany(UserEmail)
  },

  followedPosts: function () {
    return this.belongsToMany(Post).through(Follow)
  },

  linkedAccounts: function () {
    return this.hasMany(LinkedAccount)
  },

  memberships: function () {
    return this.hasMany(Membership).query({where: {active: true}})
  },

  onboarding: function () {
    return this.hasOne(Tour).query({where: {type: 'onboarding'}})
  },

  organizations: function () {
    return this.hasMany(Organization)
  },

  phones: function () {
    return this.hasMany(UserPhone)
  },

  posts: function () {
    return this.hasMany(Post)
  },
{'fraction_non_alphanumeric': 0.1430390492359932, 'fraction_numerical': 0.0, 'mean_word_length': 3.7045908183632736, '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': '1023428', 'n_tokens_mistral': 769, 'n_tokens_neox': 733, 'n_words': 141}