<commit_before>
import { observable, computed, toJS } from 'mobx';
import { omitBy, assign, isFunction, isUndefined, reduce } from 'lodash';
import getRequest from 'utils/getRequest';
import showError from 'utils/showError';
import deprecated from 'utils/deprecated';
import routerStore from 'stores/routerStore';
import ActionModalStore from 'stores/ActionModalStore';

const caches = observable.map();
let appConfig = {};
let authStore = {};

export default class DataStore {
	static get(tableName, customConfig) {
		if (caches.has(tableName)) { return caches.get(tableName); }
		const store = new DataStore(tableName, customConfig);
		caches.set(tableName, store);
		return store;
	}

	static setup(config, auth) {
		appConfig = config;
		authStore = auth;
	}

	@observable _prevFetchKey = '?';
	@observable isFetching = false;
	@observable selectedKeys = [];
	@observable data = {};

	@computed get tableConfig() {
		return {
			...appConfig.tables[this._tableName],
			...this._customConfig,
		};
	}

	@computed get collection() {
		return this.collections.get(this._prevFetchKey);
	}

	@computed get total() {
		return this.totals.get(this._prevFetchKey) || 0;
	}

	@computed get dataSource() {
		return toJS(this.collection);
	}

	@computed get sortedKey() {
		return routerStore.location.query[appConfig.api.sortKey];
	}

	@computed get sortedOrder() {
		const { orderKey, ascValue } = appConfig.api;
		const { query } = routerStore.location;
		let order = query[orderKey];

		if (!this.sortedKey) { return order; }

		/* eslint-disable eqeqeq */
		return order == ascValue ? 'ascend' : 'descend';
	}

	@computed get columns() {
		return this
			.tableConfig
			.tableRenderers
			.map(({ render, props, options }) => {
				const column = {
					title: props.label,
					key: props.name,
					dataIndex: props.name,
					render: function renderTable(text, record, index) {
						return render(props, {
							...options,
							text,
							record,
							index,
						});
					},<commit_msg>add inTable() argument value alias to text<commit_after>
import { observable, computed, toJS } from 'mobx';
import { omitBy, assign, isFunction, isUndefined, reduce } from 'lodash';
import getRequest from 'utils/getRequest';
import showError from 'utils/showError';
import deprecated from 'utils/deprecated';
import routerStore from 'stores/routerStore';
import ActionModalStore from 'stores/ActionModalStore';

const caches = observable.map();
let appConfig = {};
let authStore = {};

export default class DataStore {
	static get(tableName, customConfig) {
		if (caches.has(tableName)) { return caches.get(tableName); }
		const store = new DataStore(tableName, customConfig);
		caches.set(tableName, store);
		return store;
	}

	static setup(config, auth) {
		appConfig = config;
		authStore = auth;
	}

	@observable _prevFetchKey = '?';
	@observable isFetching = false;
	@observable selectedKeys = [];
	@observable data = {};

	@computed get tableConfig() {
		return {
			...appConfig.tables[this._tableName],
			...this._customConfig,
		};
	}

	@computed get collection() {
		return this.collections.get(this._prevFetchKey);
	}

	@computed get total() {
		return this.totals.get(this._prevFetchKey) || 0;
	}

	@computed get dataSource() {
		return toJS(this.collection);
	}

	@computed get sortedKey() {
		return routerStore.location.query[appConfig.api.sortKey];
	}

	@computed get sortedOrder() {
		const { orderKey, ascValue } = appConfig.api;
		const { query } = routerStore.location;
		let order = query[orderKey];

		if (!this.sortedKey) { return order; }

		/* eslint-disable eqeqeq */
		return order == ascValue ? 'ascend' : 'descend';
	}

	@computed get columns() {
		return this
			.tableConfig
			.tableRenderers
			.map(({ render, props, options }) => {
				const column = {
					title: props.label,
					key: props.name,
					dataIndex: props.name,
					render: function renderTable(text, record, index) {
						return render(props, {
							...options,
							text,
							value: text,
							record,
							index,
						});
					},
{'fraction_non_alphanumeric': 0.13139046678192146, 'fraction_numerical': 0.0004939491232403062, 'mean_word_length': 3.6983758700696057, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '321330', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1286, 'n_words': 326}