mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-20 21:15:01 +00:00
For large accounts with huge volumes of messages, it can be very wasteful to make the meta request so often. It also puts un-necessary load on the DB bombarding it with so many requests. This PR fixes it by throttling the requests to 5 seconds for all users with more than 1000 accessible chats. ### Why not cache this value in the backend? Well, it's a bit tricky, since a user can have different permissions over inboxes and can see different chats, maintaining a cache for each of them is not effective, besides the requests will reach the server anyway.
22 lines
546 B
JavaScript
22 lines
546 B
JavaScript
import types from '../../../mutation-types';
|
|
import { mutations } from '../../conversationStats';
|
|
|
|
describe('#mutations', () => {
|
|
describe('#SET_CONV_TAB_META', () => {
|
|
it('set conversation stats correctly', () => {
|
|
const state = {};
|
|
mutations[types.SET_CONV_TAB_META](state, {
|
|
mine_count: 1,
|
|
unassigned_count: 1,
|
|
all_count: 2,
|
|
});
|
|
expect(state).toEqual({
|
|
mineCount: 1,
|
|
unAssignedCount: 1,
|
|
allCount: 2,
|
|
updatedOn: expect.any(Date),
|
|
});
|
|
});
|
|
});
|
|
});
|