<commit_before>// @flow
import casual from "casual-browserify"
import R from "ramda"

import { LINK_TYPE_ANY } from "../lib/channels"
import { incrementer } from "../factories/util"

import type {
  Channel,
  Contributor,
  ChannelContributors,
  ChannelModerators,
  Moderator
} from "../flow/discussionTypes"

const incr = incrementer()

export const makeChannel = (privateChannel: boolean = false): Channel => ({
  // $FlowFixMe: Flow thinks incr.next().value may be undefined, but it won't ever be
  name:                  `channel_${incr.next().value}`,
  title:                 casual.title,
  channel_type:          privateChannel ? "private" : "public",
  link_type:             LINK_TYPE_ANY,
  description:           casual.description,
  public_description:    casual.description,
  num_users:             casual.integer(0, 500),
  user_is_contributor:   casual.coin_flip,
  user_is_moderator:     casual.coin_flip,
  membership_is_managed: casual.coin_flip
})

export const makeChannelList = (numChannels: number = 20) => {
  return R.range(0, numChannels).map(() => makeChannel(Math.random() > 0.5))
}

export const makeContributor = (username: ?string = null): Contributor => ({
  contributor_name: username || casual.word,
  email:            casual.email,
  full_name:        casual.full_name
})

export const makeContributors = (
  username: ?string = null
): ChannelContributors => [
  makeContributor(username),
  makeContributor(null),
  makeContributor(null)
]

export const makeModerator = (
  username: ?string = null,
  isModerator: ?boolean
): Moderator => ({
  moderator_name: username || casual.word,
  ...(isModerator<commit_msg>Fixed contributor and moderator factories for username collisions<commit_after>// @flow
import casual from "casual-browserify"
import R from "ramda"

import { LINK_TYPE_ANY } from "../lib/channels"
import { incrementer } from "../factories/util"

import type {
  Channel,
  Contributor,
  ChannelContributors,
  ChannelModerators,
  Moderator
} from "../flow/discussionTypes"

const incr = incrementer()

export const makeChannel = (privateChannel: boolean = false): Channel => ({
  // $FlowFixMe: Flow thinks incr.next().value may be undefined, but it won't ever be
  name:                  `channel_${incr.next().value}`,
  title:                 casual.title,
  channel_type:          privateChannel ? "private" : "public",
  link_type:             LINK_TYPE_ANY,
  description:           casual.description,
  public_description:    casual.description,
  num_users:             casual.integer(0, 500),
  user_is_contributor:   casual.coin_flip,
  user_is_moderator:     casual.coin_flip,
  membership_is_managed: casual.coin_flip
})

export const makeChannelList = (numChannels: number = 20) => {
  return R.range(0, numChannels).map(() => makeChannel(Math.random() > 0.5))
}

export const makeContributor = (username: ?string = null): Contributor => ({
  // $FlowFixMe: Flow thinks incr.next().value may be undefined, but it won't ever be
  contributor_name: username || `${casual.word}_${incr.next().value}`,
  email:            casual.email,
  full_name:        casual.full_name
})

export const makeContributors = (
  username: ?string = null
): ChannelContributors => [
  makeContributor(username),
  makeContributor(null),
  makeContributor(null)
]

export const makeModerator = (
  username: ?string = null,
  isModerator: ?boolean
): Moderator => ({
  // $FlowFixMe: Flow thinks incr.next().value may be undefined, but it won't ever be
  moderator_name: username || `${casual.word}_${incr.next().value}`,
  ...(isModerator
{'fraction_non_alphanumeric': 0.12360801781737193, 'fraction_numerical': 0.005011135857461025, 'mean_word_length': 3.582908163265306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '4380095', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1111, 'n_words': 270}