mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
- scripts to throttle reindex job creation and monitor progress ``` RAILS_ENV=production POSTGRES_STATEMENT_TIMEOUT=6000s bundle exec rails runner script/bulk_reindex_messages.rb RAILS_ENV=production bundle exec rails runner script/monitor_reindex.rb ``` --------- Co-authored-by: Pranav <pranavrajs@gmail.com>
75 lines
1.6 KiB
JavaScript
75 lines
1.6 KiB
JavaScript
import types from '../mutation-types';
|
|
import ConversationApi from '../../api/inbox/conversation';
|
|
import { debounce } from '@chatwoot/utils';
|
|
|
|
const state = {
|
|
mineCount: 0,
|
|
unAssignedCount: 0,
|
|
allCount: 0,
|
|
};
|
|
|
|
export const getters = {
|
|
getStats: $state => $state,
|
|
};
|
|
|
|
// Create a debounced version of the actual API call function
|
|
const fetchMetaData = async (commit, params) => {
|
|
try {
|
|
const response = await ConversationApi.meta(params);
|
|
const {
|
|
data: { meta },
|
|
} = response;
|
|
commit(types.SET_CONV_TAB_META, meta);
|
|
} catch (error) {
|
|
// ignore
|
|
}
|
|
};
|
|
|
|
const debouncedFetchMetaData = debounce(fetchMetaData, 500, false, 1500);
|
|
const longDebouncedFetchMetaData = debounce(fetchMetaData, 5000, false, 10000);
|
|
const superLongDebouncedFetchMetaData = debounce(
|
|
fetchMetaData,
|
|
10000,
|
|
false,
|
|
20000
|
|
);
|
|
|
|
export const actions = {
|
|
get: async ({ commit, state: $state }, params) => {
|
|
if ($state.allCount > 5000) {
|
|
superLongDebouncedFetchMetaData(commit, params);
|
|
} else if ($state.allCount > 100) {
|
|
longDebouncedFetchMetaData(commit, params);
|
|
} else {
|
|
debouncedFetchMetaData(commit, params);
|
|
}
|
|
},
|
|
set({ commit }, meta) {
|
|
commit(types.SET_CONV_TAB_META, meta);
|
|
},
|
|
};
|
|
|
|
export const mutations = {
|
|
[types.SET_CONV_TAB_META](
|
|
$state,
|
|
{
|
|
mine_count: mineCount,
|
|
unassigned_count: unAssignedCount,
|
|
all_count: allCount,
|
|
} = {}
|
|
) {
|
|
$state.mineCount = mineCount;
|
|
$state.allCount = allCount;
|
|
$state.unAssignedCount = unAssignedCount;
|
|
$state.updatedOn = new Date();
|
|
},
|
|
};
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state,
|
|
getters,
|
|
actions,
|
|
mutations,
|
|
};
|