<commit_before>import { put, takeLatest, call, select } from 'redux-saga/effects';
import * as types from 'builder/actions/actionTypes';
import { teamValidationFetcher as fetcher } from 'builder/validations/requests/fetchers';
import { validateTeamSuccess } from 'builder/validations/actions';

import { selectAssets } from 'builder/assets/selectors';
import { selectChosenAffinities } from 'builder/affinities/selectors';
import { selectBaseRank } from 'builder/sponsors/selectors';
import { selectUnits } from 'builder/units/selectors';

function fetch(params) {
   return fetcher.fetch(params);
}

function* requestValidation(action) {
   const response = yield call(fetch, action.params);
   yield put(validateTeamSuccess(response.payload));
}

function* build(action) {
   yield put({ type: types.SET_BASE_RANK, payload: action.payload.baseRank });
   yield put({ type: types.SET_RANK, payload: action.payload.currentRank });
   yield put({ type: types.SET_TEAM_VALUE, payload: action.payload.valoration });
}

function* validateTeam() {
   const assets = yield select(selectAssets);
   const affinities = yield select(selectChosenAffinities);
   const units = yield select(selectUnits);
   const baseRank = yield select(selectBaseRank);

   const params = { affinities, units, baseRank, ...assets };
   yield call(requestValidation, { params });
}

export const validationSagas = [
   takeLatest(types.SET_CHEERLEADERS, validateTeam),
   takeLatest(types.SET_COACHING_DICE, validateTeam),
   takeLatest(types.SET_MEDIBOT, validateTeam),
   takeLatest(types.SET_NASTY_SURPRISE_CARD, validateTeam),
   takeLatest(types.SET_SPECIAL_MOVE_CARD, validateTeam),
   takeLatest(types.SET_WAGER, validateTeam),
   takeLatest(types.ADD_TEAM_UNIT, validateTeam),
   takeLatest(types.REMOVE_TEAM_UNIT, validateTeam),
   takeLatest(types.REQUEST_SUCCESS_TEAM_VALIDATION, build)
];
<commit_msg>Fixed validation parameters<commit_after>import { put, takeLatest, call, select } from 'redux-saga/effects';
import * as types from 'builder/actions/actionTypes';
import { teamValidationFetcher as fetcher } from 'builder/validations/requests/fetchers';
import { validateTeamSuccess } from 'builder/validations/actions';

import { selectAssets } from 'builder/assets/selectors';
import { selectChosenAffinities } from 'builder/affinities/selectors';
import { selectBaseRank } from 'builder/sponsors/selectors';
import { selectUnits } from 'builder/units/selectors';

function fetch(params) {
   return fetcher.fetch(params);
}

function* requestValidation(action) {
   const response = yield call(fetch, action.params);
   yield put(validateTeamSuccess(response.payload));
}

function* build(action) {
   yield put({ type: types.SET_BASE_RANK, payload: action.payload.baseRank });
   yield put({ type: types.SET_RANK, payload: action.payload.currentRank });
   yield put({ type: types.SET_TEAM_VALUE, payload: action.payload.totalCost });
}

function* validateTeam() {
   const assets = yield select(selectAssets);
   const affinities = yield select(selectChosenAffinities);
   const teamPlayers = yield select(selectUnits);
   const baseRank = yield select(selectBaseRank);

   const params = { affinities, teamPlayers, baseRank, ...assets };
   yield call(requestValidation, { params });
}

export const validationSagas = [
   takeLatest(types.SET_CHEERLEADERS, validateTeam),
   takeLatest(types.SET_COACHING_DICE, validateTeam),
   takeLatest(types.SET_MEDIBOT, validateTeam),
   takeLatest(types.SET_NASTY_SURPRISE_CARD, validateTeam),
   takeLatest(types.SET_SPECIAL_MOVE_CARD, validateTeam),
   takeLatest(types.SET_WAGER, validateTeam),
   takeLatest(types.ADD_TEAM_UNIT, validateTeam),
   takeLatest(types.REMOVE_TEAM_UNIT, validateTeam),
   takeLatest(types.REQUEST_SUCCESS_TEAM_VALIDATION, build)
];

{'fraction_non_alphanumeric': 0.11067193675889328, 'fraction_numerical': 0.0, 'mean_word_length': 6.0166358595194085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2758881', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1156, 'n_words': 240}