<commit_before>import topics from './topics';
import users from './users';
import proposals from './proposals';
import _ from 'lodash';

function isReversimTeamMember(loggedInUser) {
  return loggedInUser && loggedInUser.isReversimTeamMember;
}

export function transformUser(user, loggedInUser, overrideDetails) {
  if (user._doc) {
    user = user._doc;
  }

  let isReversimMember = overrideDetails || isReversimTeamMember(loggedInUser);

  if (_.isObject(user) && _.has(user, 'profile')) {
    return {
      _id: user._id,
      proposals: user.proposals && user.proposals.map(p => transformProposal(p, loggedInUser, overrideDetails)),
      name: user.profile && user.profile.name,
      oneLiner: user.profile && user.profile.oneLiner,
      email: isReversimMember && user.email,
      trackRecord: isReversimMember && user.profile.trackRecord,
      isReversimTeamMember: user.isReversimTeamMember,
      bio: user.profile && user.profile.bio,
      gender: user.profile && user.profile.gender,
      picture: user.profile && user.profile.picture,
      linkedin: user.profile && user.profile.linkedin,
      twitter: user.profile && user.profile.twitter,
      stackOverflow: user.profile && user.profile.stackOverflow,
      phone: user.profile && user.profile.phone
    };
  }

  return user;
}

export function transformProposal(proposal, loggedInUser, overrideDetails) {

  if (_.isObject(proposal)) {
    let isReversimMember = overrideDetails || isReversimTeamMember(loggedInUser);

    return {
      id: proposal.id,
      title: proposal.title,
      abstract: proposal.abstract,
      type: proposal.type,
      tags: proposal.tags,
      status: proposal.status,
      speaker_ids: proposal.speaker_ids && proposal.speaker_ids.map((user) => {
        return transformUser(user, loggedInUser, overrideDetails);
      }),
      startTime: proposal.startTime,
      endTime: proposal.endTime,
      hall: proposal.hall,
      slides_gdrive_id: proposal.slides_gdrive_id,
      video_url: proposal.video_url,
      outline: proposal.outline,
      total: (proposal.attendees && isReversimMember) ? proposal.attendees.length : undefined,
      attended: proposal.attendees && (loggedInUser ? proposal.attendees.indexOf(loggedInUser._id) > -1 : false)
    }
  }

  return proposal;
}

export default {
  transformUser,
  transformProposal
};<commit_msg>private data<commit_after>import topics from './topics';
import users from './users';
import proposals from './proposals';
import _ from 'lodash';

function isReversimTeamMember(loggedInUser) {
  return loggedInUser && loggedInUser.isReversimTeamMember;
}

export function transformUser(user, loggedInUser) {
  if (user._doc) {
    user = user._doc;
  }

  let isReversimMember = isReversimTeamMember(loggedInUser);

  if (_.isObject(user) && _.has(user, 'profile')) {
    return {
      _id: user._id,
      proposals: user.proposals && user.proposals.map(p => transformProposal(p, loggedInUser)),
      name: user.profile && user.profile.name,
      oneLiner: user.profile && user.profile.oneLiner,
      email: isReversimMember && user.email,
      trackRecord: isReversimMember && user.profile.trackRecord,
      isReversimTeamMember: user.isReversimTeamMember,
      bio: user.profile && user.profile.bio,
      gender: user.profile && user.profile.gender,
      picture: user.profile && user.profile.picture,
      linkedin: user.profile && user.profile.linkedin,
      twitter: user.profile && user.profile.twitter,
      stackOverflow: user.profile && user.profile.stackOverflow,
      phone: isReversimMember && user.profile && user.profile.phone
    };
  }

  return user;
}

export function transformProposal(proposal, loggedInUser) {

  if (_.isObject(proposal)) {
    let isReversimMember = isReversimTeamMember(loggedInUser);

    return {
      id: proposal.id,
      title: proposal.title,
      abstract: proposal.abstract,
      type: proposal.type,
      tags: proposal.tags,
      status: isReversimMember && proposal.status,
      speaker_ids: proposal.speaker_ids && proposal.speaker_ids.map((user) => {
        return transformUser(user, loggedInUser);
      }),
      startTime: proposal.startTime,
      endTime: proposal.endTime,
      hall: proposal.hall,
      slides_gdrive_id: proposal.slides_gdrive_id,
      video_url: isReversimMember && proposal.video_url,
      outline: isReversimMember && proposal.outline,
      total: (proposal.attendees && isReversimMember) ? proposal.attendees.length : undefined,
      attended: proposal.attendees && (loggedInUser ? proposal.attendees.indexOf(loggedInUser._id) > -1 : false)
    }
  }

  return proposal;
}

export default {
  transformUser,
  transformProposal
};
{'fraction_non_alphanumeric': 0.1146740284561478, 'fraction_numerical': 0.00042471862391165854, 'mean_word_length': 3.62671905697446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3817171', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1445, 'n_words': 285}