<commit_before>import alt from '../alt';
import RunActions from '../actions/RunActions';
import UserActions from '../actions/UserActions';
import UserApiUtils from '../utils/UserApiUtils';
import RunApiUtils from '../utils/RunApiUtils';

class UserStore {
  constructor() {
    this.user = UserStore.getDefaultUser();
    this.bindAction(UserActions.receivedCurrentUser, this.onReceivedCurrentUser);
  }

  onReceivedCurrentUser(user) {
    this.user = user;

    // Now fetch queries for that user.
    RunApiUtils.fetchForUser(this.user).then((results) => {
      RunActions.addMultipleRuns(results);
    });
  }

  onFetchCurrentUser() {
    UserApiUtils.fetchCurrentUser().then((user) => {
      UserActions.receivedCurrentUser(user);
    });
    return false;
  }

  static getDefaultUser() {
    return {
      name: 'unknown',
      executionPermissions: {
        accessLevel: 'default',<commit_msg>[fix-load-user] Fix loading user queries<commit_after>import alt from '../alt';
import RunActions from '../actions/RunActions';
import UserActions from '../actions/UserActions';
import UserApiUtils from '../utils/UserApiUtils';
import RunApiUtils from '../utils/RunApiUtils';

class UserStore {
  constructor() {
    this.user = UserStore.getDefaultUser();
    this.bindAction(UserActions.receivedCurrentUser, this.onReceivedCurrentUser);
    this.bindAction(UserActions.fetchCurrentUser, this.onFetchCurrentUser);
  }

  onReceivedCurrentUser(user) {
    this.user = user;

    // Now fetch queries for that user.
    RunApiUtils.fetchForUser(this.user).then((results) => {
      RunActions.addMultipleRuns(results);
    });
  }

  onFetchCurrentUser() {
    UserApiUtils.fetchCurrentUser().then((user) => {
      UserActions.receivedCurrentUser(user);
    });
    return false;
  }

  static getDefaultUser() {
    return {
      name: 'unknown',
      executionPermissions: {
        accessLevel: 'default',
{'fraction_non_alphanumeric': 0.1298904538341158, 'fraction_numerical': 0.0, 'mean_word_length': 3.7241379310344827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3747350', 'n_tokens_mistral': 552, 'n_tokens_neox': 542, 'n_words': 107}