<commit_before>import { push } from "connected-react-router";
import { includes } from "lodash-es";
import {
    CREATE_SAMPLE,
    FIND_READ_FILES,
    FIND_READY_HOSTS,
    FIND_SAMPLES,
    GET_SAMPLE,
    REMOVE_SAMPLE,
    UPDATE_SAMPLE,
    UPDATE_SAMPLE_RIGHTS,
    UPLOAD_SAMPLE_FILE
} from "../app/actionTypes";

import * as filesAPI from "../files/api";
import { createUploadChannel, watchUploadChannel } from "../files/sagas";
import { apiCall, putGenericError, setPending } from "../utils/sagas";
import * as samplesAPI from "./api";
import { createFindURL } from "./utils";
import { call, put, select, takeEvery, takeLatest, throttle } from "redux-saga/effects";

export function* watchSamples() {
    yield throttle(300, FIND_SAMPLES.REQUESTED, findSamples);
    yield takeLatest(FIND_READY_HOSTS.REQUESTED, findReadyHosts);
    yield takeLatest(FIND_READ_FILES.REQUESTED, findReadFiles);
    yield takeLatest(GET_SAMPLE.REQUESTED, getSample);
    yield takeLatest(CREATE_SAMPLE.REQUESTED, createSample);
    yield takeEvery(UPDATE_SAMPLE.REQUESTED, updateSample);
    yield takeEvery(UPDATE_SAMPLE_RIGHTS.REQUESTED, updateSampleRights);
    yield takeEvery(UPLOAD_SAMPLE_FILE.REQUESTED, uploadSampleFile);
    yield throttle(300, REMOVE_SAMPLE.REQUESTED, removeSample);
}

export function* findSamples(action) {
    yield apiCall(samplesAPI.find, action, FIND_SAMPLES);

    const { term, pathoscope, nuvs } = action;

    const { pathname, search } = createFindURL(term, pathoscope, nuvs);

    yield put(push(pathname + search));
}

export function* findReadFiles() {
    yield apiCall(
        filesAPI.find,<commit_msg>Update current sample detail in response to matching websocket message<commit_after>import { push } from "connected-react-router";
import { includes } from "lodash-es";
import {
    CREATE_SAMPLE,
    FIND_READ_FILES,
    FIND_READY_HOSTS,
    FIND_SAMPLES,
    GET_SAMPLE,
    REMOVE_SAMPLE,
    UPDATE_SAMPLE,
    UPDATE_SAMPLE_RIGHTS,
    UPLOAD_SAMPLE_FILE,
    WS_UPDATE_SAMPLE
} from "../app/actionTypes";

import * as filesAPI from "../files/api";
import { createUploadChannel, watchUploadChannel } from "../files/sagas";
import { apiCall, putGenericError, setPending } from "../utils/sagas";
import * as samplesAPI from "./api";
import { getSampleDetailId } from "./selectors";
import { createFindURL } from "./utils";
import { call, put, select, takeEvery, takeLatest, throttle } from "redux-saga/effects";

export function* watchSamples() {
    yield throttle(300, FIND_SAMPLES.REQUESTED, findSamples);
    yield takeLatest(FIND_READY_HOSTS.REQUESTED, findReadyHosts);
    yield takeLatest(FIND_READ_FILES.REQUESTED, findReadFiles);
    yield takeLatest(GET_SAMPLE.REQUESTED, getSample);
    yield takeLatest(CREATE_SAMPLE.REQUESTED, createSample);
    yield takeEvery(UPDATE_SAMPLE.REQUESTED, updateSample);
    yield takeEvery(UPDATE_SAMPLE_RIGHTS.REQUESTED, updateSampleRights);
    yield takeEvery(UPLOAD_SAMPLE_FILE.REQUESTED, uploadSampleFile);
    yield throttle(300, REMOVE_SAMPLE.REQUESTED, removeSample);
    yield takeEvery(WS_UPDATE_SAMPLE, wsUpdateSample);
}

export function* wsUpdateSample(action) {
    const sampleDetailId = yield select(getSampleDetailId);
    if (action.data.id === sampleDetailId) {
        yield apiCall(samplesAPI.get, { sampleId: sampleDetailId }, GET_SAMPLE);
    }
}

export function* findSamples(action) {
    yield apiCall(samplesAPI.find, action, FIND_SAMPLES);

    const { term, pathoscope, nuvs } = action;

    const { pathname, search } = createFindURL(term, pathoscope, nuvs);

    yield put(push(pathname + search));
}

export function* findReadFiles() {
    yield apiCall(
        filesAPI.find,
{'fraction_non_alphanumeric': 0.10687229437229437, 'fraction_numerical': 0.003246753246753247, 'mean_word_length': 4.749611197511664, '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': '1981718', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1168, 'n_words': 257}