<commit_before>import { getDataTypeForModel } from '../group/DataType'

export default {
  // note that this `where` argument is applied to the subquery;
  // to add clauses to the outer query, just use `.query` on the
  // result of this method
  queryByGroupMembership (model, { where } = {}) {
    const dataType = getDataTypeForModel(model)

    let subq = GroupMembership.query()
    .join('groups', 'groups.id', 'group_memberships.group_id')
    .where({
      user_id: this.id,
      group_data_type: dataType,
      'group_memberships.active': true
    })
    .select('group_data_id')

    if (where) subq = subq.where(where)

    return model.collection().query(q => q.where('id', 'in', subq))
  },

  communitiesNotImplementedYet () {
    return this.queryByGroupMembership(Community)
  }<commit_msg>cleanup<commit_after>import { getDataTypeForModel } from '../group/DataType'

export default {
  // note that this `where` argument is applied to the subquery;
  // to add clauses to the outer query, just use `.query` on the
  // result of this method
  queryByGroupMembership (model, { where } = {}) {
    const dataType = getDataTypeForModel(model)

    let subq = GroupMembership.query()
    .join('groups', 'groups.id', 'group_memberships.group_id')
    .where({
      user_id: this.id,
      group_data_type: dataType,
      'group_memberships.active': true
    })
    .select('group_data_id')

    if (where) subq = subq.where(where)

    return model.collection().query(q => q.where('id', 'in', subq))
  }
{'fraction_non_alphanumeric': 0.13272010512483573, 'fraction_numerical': 0.0, 'mean_word_length': 3.4144927536231884, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7542504', 'n_tokens_mistral': 491, 'n_tokens_neox': 483, 'n_words': 125}