Skip to content

Commit

Permalink
Update polling intervals in watchHistory, entryPointStore, and notifi…
Browse files Browse the repository at this point in the history
…cationsStore
  • Loading branch information
davelopez committed Jan 30, 2024
1 parent 63b5850 commit f2d4484
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 5 additions & 2 deletions client/src/store/historyStore/model/watchHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ import { useDatasetStore } from "@/stores/datasetStore";

const limit = 1000;

const ACTIVE_POLLING_INTERVAL = 3000;
const INACTIVE_POLLING_INTERVAL = 60000;

// last time the history has changed
let lastUpdateTime = null;

// last time changed history items have been requested
let lastRequestDate = new Date();

const { startWatchingResource: startWatchingHistory } = useResourceWatcher(watchHistory, {
shortPollingInterval: 3000,
longPollingInterval: 60000,
shortPollingInterval: ACTIVE_POLLING_INTERVAL,
longPollingInterval: INACTIVE_POLLING_INTERVAL,
});

export { startWatchingHistory };
Expand Down
6 changes: 4 additions & 2 deletions client/src/stores/entryPointStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { useResourceWatcher } from "@/composables/resourceWatcher";
import { getAppRoot } from "@/onload/loadConfig";
import { rethrowSimple } from "@/utils/simple-error";

const ACTIVE_POLLING_INTERVAL = 10000;

// TODO: replace with the corresponding autogenerated model when ready
interface EntryPoint {
model_class: "InteractiveToolEntryPoint";
Expand All @@ -22,8 +24,8 @@ interface EntryPoint {

export const useEntryPointStore = defineStore("entryPointStore", () => {
const { startWatchingResource: startWatchingEntryPoints } = useResourceWatcher(fetchEntryPoints, {
shortPollingInterval: 10000,
enableBackgroundPolling: false, //No need to poll when the user is not on the page
shortPollingInterval: ACTIVE_POLLING_INTERVAL,
enableBackgroundPolling: false, // No need to poll in the background
});

const entryPoints = ref<EntryPoint[]>([]);
Expand Down
7 changes: 5 additions & 2 deletions client/src/stores/notificationsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import { mergeObjectListsById } from "@/utils/utils";

import { useBroadcastsStore } from "./broadcastsStore";

const ACTIVE_POLLING_INTERVAL = 5000;
const INACTIVE_POLLING_INTERVAL = 30000;

export const useNotificationsStore = defineStore("notificationsStore", () => {
const { startWatchingResource: startWatchingNotifications } = useResourceWatcher(getNotificationStatus, {
shortPollingInterval: 5000,
longPollingInterval: 30000,
shortPollingInterval: ACTIVE_POLLING_INTERVAL,
longPollingInterval: INACTIVE_POLLING_INTERVAL,
});
const broadcastsStore = useBroadcastsStore();

Expand Down

0 comments on commit f2d4484

Please sign in to comment.