<commit_before>import {
  ADVANCE,
  LOAD_HISTORY_START, LOAD_HISTORY_COMPLETE
} from '../constants/actionTypes/booth';
import { flattenPlaylistItem } from './PlaylistActionCreators';
import { get } from '../utils/Request';

/**
 * Set the current song and DJ.
 */
export function advance(nextBooth) {
  if (!nextBooth) {
    return {
      type: ADVANCE,
      payload: null
    };
  }
  const { media, userID, historyID, playlistID, played } = nextBooth;
  return {
    type: ADVANCE,
    payload: {
      userID, historyID, playlistID,
      media: flattenPlaylistItem(media),
      timestamp: played
    }
  };
}

export function loadHistory() {
  return dispatch => {
    dispatch({ type: LOAD_HISTORY_START });
    get(null, '/v1/booth/history')
      .then(res => res.json())
      .then(history => {
        dispatch({
          type: LOAD_HISTORY_COMPLETE,
          payload: history.result,
          meta: {
            page: history.page,
            size: history.size
          }
        });
      });
  };
}<commit_msg>booth: add the full user object to the ADVANCE action<commit_after>import {
  ADVANCE,
  LOAD_HISTORY_START, LOAD_HISTORY_COMPLETE
} from '../constants/actionTypes/booth';
import { flattenPlaylistItem } from './PlaylistActionCreators';
import { get } from '../utils/Request';

import { usersSelector } from '../selectors/userSelectors';

/**
 * Set the current song and DJ.
 */
export function advance(nextBooth) {
  if (!nextBooth) {
    return {
      type: ADVANCE,
      payload: null
    };
  }
  const { media, userID, historyID, playlistID, played } = nextBooth;
  return (dispatch, getState) => {
    const user = usersSelector(getState())[userID];
    dispatch({
      type: ADVANCE,
      payload: {
        userID, historyID, playlistID, user,
        media: flattenPlaylistItem(media),
        timestamp: played
      }
    });
  };
}

export function loadHistory() {
  return dispatch => {
    dispatch({ type: LOAD_HISTORY_START });
    get(null, '/v1/booth/history')
      .then(res => res.json())
      .then(history => {
        dispatch({
          type: LOAD_HISTORY_COMPLETE,
          payload: history.result,
          meta: {
            page: history.page,
            size: history.size
          }
        });
      });
  };
}
{'fraction_non_alphanumeric': 0.12992125984251968, 'fraction_numerical': 0.0008748906386701663, 'mean_word_length': 2.428785607196402, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '108992', 'n_tokens_mistral': 725, 'n_tokens_neox': 727, 'n_words': 162}