<commit_before>import { put, takeEvery, takeLatest } from "redux-saga/effects";

import * as indexesAPI from "./api";
import { get as getReference } from "../references/api";
import { apiCall, setPending } from "../sagaUtils";
import {
    WS_UPDATE_INDEX,
    FIND_INDEXES,
    GET_INDEX,
    GET_UNBUILT,
    CREATE_INDEX,
    GET_INDEX_HISTORY,
    GET_REFERENCE, LIST_READY_INDEXES
} from "../actionTypes";

export function* watchIndexes () {
    yield takeLatest(WS_UPDATE_INDEX, wsUpdateIndex);
    yield takeLatest(FIND_INDEXES.REQUESTED, findIndexes);
    yield takeLatest(GET_INDEX.REQUESTED, getIndex);
    yield takeLatest(GET_UNBUILT.REQUESTED, getUnbuilt);
    yield takeEvery(CREATE_INDEX.REQUESTED, createIndex);
    yield takeLatest(GET_INDEX_HISTORY.REQUESTED, getIndexHistory);
    yield takeLatest(LIST_READY_INDEXES.REQUESTED, listReadyIndexes);
}

export function* wsUpdateIndex (action) {
    yield findIndexes({ refId: action.data.reference.id, page: 1 });
    yield apiCall(getReference, { referenceId: action.data.reference.id }, GET_REFERENCE);
}

export function* findIndexes (action) {
    yield apiCall(indexesAPI.find, action, FIND_INDEXES);
}

export function* getIndex (action) {
    yield apiCall(indexesAPI.get, action, GET_INDEX);
}

export function* getUnbuilt (action) {
    yield apiCall(indexesAPI.getUnbuilt, action, GET_UNBUILT);
}

export function* listReadyIndexes (action) {
    yield apiCall(indexesAPI.listReady, action, LIST_READY_INDEXES);
}

export function* createIndex (action) {
    yield setPending(apiCall(indexesAPI.create, action, CREATE_INDEX));
    yield put({
        type: FIND_INDEXES.REQUESTED,
        refId: action.refId,
        page: 1
    });
}

export function* getIndexHistory (action) {
    yield setPending(apiCall(indexesAPI.getHistory, action, GET_INDEX_HISTORY));
}
<commit_msg>Fix reference index list creation bug<commit_after>import { put, takeEvery, takeLatest, select } from "redux-saga/effects";
import * as indexesAPI from "./api";
import { apiCall, setPending } from "../sagaUtils";
import {
    WS_UPDATE_INDEX,
    FIND_INDEXES,
    GET_INDEX,
    GET_UNBUILT,
    CREATE_INDEX,
    GET_INDEX_HISTORY,
    GET_REFERENCE,
    LIST_READY_INDEXES
} from "../actionTypes";

export function* watchIndexes () {
    yield takeLatest(WS_UPDATE_INDEX, wsUpdateIndex);
    yield takeLatest(FIND_INDEXES.REQUESTED, findIndexes);
    yield takeLatest(GET_INDEX.REQUESTED, getIndex);
    yield takeLatest(GET_UNBUILT.REQUESTED, getUnbuilt);
    yield takeEvery(CREATE_INDEX.REQUESTED, createIndex);
    yield takeLatest(GET_INDEX_HISTORY.REQUESTED, getIndexHistory);
    yield takeLatest(LIST_READY_INDEXES.REQUESTED, listReadyIndexes);
}

export function* wsUpdateIndex (action) {
    const refId = yield select(state => state.references.detail.id);

    if (refId === action.data.reference.id) {
        yield findIndexes({ refId: action.data.reference.id, page: 1 });
    }
}

export function* findIndexes (action) {
    yield apiCall(indexesAPI.find, action, FIND_INDEXES);
}

export function* getIndex (action) {
    yield apiCall(indexesAPI.get, action, GET_INDEX);
}

export function* getUnbuilt (action) {
    yield apiCall(indexesAPI.getUnbuilt, action, GET_UNBUILT);
}

export function* listReadyIndexes (action) {
    yield apiCall(indexesAPI.listReady, action, LIST_READY_INDEXES);
}

export function* createIndex (action) {
    yield setPending(apiCall(indexesAPI.create, action, CREATE_INDEX));
    yield put({
        type: FIND_INDEXES.REQUESTED,
        refId: action.refId,
        page: 1
    });
}

export function* getIndexHistory (action) {
    yield setPending(apiCall(indexesAPI.getHistory, action, GET_INDEX_HISTORY));
}

{'fraction_non_alphanumeric': 0.10707559860102232, 'fraction_numerical': 0.0010761366693570083, 'mean_word_length': 4.61631419939577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6620873', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1224, 'n_words': 259}