<commit_before>/*
Showing list of users of a project
*/
import { Component, React, redux, rclass, rtypes } from "../app-framework";
import { UserMap } from "../todo-types";

const { User } = require("../users");
const { Loading, r_join } = require("../r_misc");

interface ReactProps {
  project: any;
  none?: React.ComponentType<any>;
}

interface ReduxProps {
  user_map: UserMap;
  account_id: string;
}

export const ProjectUsers = rclass<ReactProps>(
  class ProjectUsers extends Component<ReactProps & ReduxProps> {
    static reduxProps = () => {
      return {
        users: {
          user_map: rtypes.immutable
        },
        account: {
          account_id: rtypes.string
        }
      };
    };

    render() {
      if (this.props.user_map == undefined) {
        return <Loading />;
      }
      const users = this.props.project.get("users");
      let user_array: any[];
      if (users != undefined) {
        user_array = users.keySeq().toArray();
      } else {
        user_array = [];
      }

      const other: any[] = [];
      for (const account_id of user_array) {
        if (account_id !== this.props.account_id) {
          other.push({ account_id });
        }
      }

      redux
        .getStore("projects")
        .sort_by_activity(other, this.props.project.get("project_id"));
      const v: any = [];
      for (const user of other) {
        v.push(
          <User
            key={user.account_id}
            last_active={user.last_active}
            account_id={user.account_id}
            user_map={this.props.user_map}
          />
        );
      }
      if (v.length > 0) {
        return r_join(v);
      } else if (this.props.none) {
        return this.props.none;
      } else {
        return <span />;
      }
    }
  }
);
<commit_msg>Comment on some non-obvious code<commit_after>/*
Showing list of users of a project
*/
import { Component, React, redux, rclass, rtypes } from "../app-framework";
import { UserMap } from "../todo-types";

const { User } = require("../users");
const { Loading, r_join } = require("../r_misc");

interface ReactProps {
  project: any;
  none?: React.ComponentType<any>;
}

interface ReduxProps {
  user_map: UserMap;
  account_id: string;
}

export const ProjectUsers = rclass<ReactProps>(
  class ProjectUsers extends Component<ReactProps & ReduxProps> {
    static reduxProps = () => {
      return {
        users: {
          user_map: rtypes.immutable
        },
        account: {
          account_id: rtypes.string
        }
      };
    };

    render() {
      if (this.props.user_map == undefined) {
        return <Loading />;
      }
      const users = this.props.project.get("users");
      let user_array: any[];
      if (users != undefined) {
        user_array = users.keySeq().toArray();
      } else {
        user_array = [];
      }

      let other: { account_id: string; last_active?: number }[] = [];
      for (const account_id of user_array) {
        if (account_id !== this.props.account_id) {
          other.push({ account_id });
        }
      }

      // injects last_active
      other = redux
        .getStore("projects")
        .sort_by_activity(other, this.props.project.get("project_id"));

      const v: any = [];
      for (const user of other) {
        v.push(
          <User
            key={user.account_id}
            last_active={user.last_active}
            account_id={user.account_id}
            user_map={this.props.user_map}
          />
        );
      }
      if (v.length > 0) {
        return r_join(v);
      } else if (this.props.none) {
        return this.props.none;
      } else {
        return <span />;
      }
    }
  }
);

{'fraction_non_alphanumeric': 0.137987012987013, 'fraction_numerical': 0.0005411255411255411, 'mean_word_length': 1.9364575059571087, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, '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': '240000', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1147, 'n_words': 250}