mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Optimize history watcher for detailed contents
This will requests the detailed view only for those items that are currently expanded in the history panel instead of all of them.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
import defaultStore from "store/index";
|
||||
import { urlData } from "utils/url";
|
||||
import { loadSet } from "utils/setCache";
|
||||
import { getCurrentHistoryFromServer } from "./queries";
|
||||
import { getGalaxyInstance } from "app";
|
||||
|
||||
@@ -52,12 +53,16 @@ export async function watchHistoryOnce(store) {
|
||||
lastUpdateTime = history.update_time;
|
||||
// execute request to obtain recently changed items
|
||||
const params = {
|
||||
v: "dev",
|
||||
limit: limit,
|
||||
q: "update_time-ge",
|
||||
qv: lastRequestDate.toISOString(),
|
||||
v: "dev",
|
||||
view: "detailed",
|
||||
};
|
||||
// request detailed info only for the expanded datasets
|
||||
const detailedIds = getCurrentlyExpandedHistoryContentIds();
|
||||
if (detailedIds.length) {
|
||||
params["details"] = detailedIds.join(",");
|
||||
}
|
||||
const url = `api/histories/${historyId}/contents`;
|
||||
lastRequestDate = new Date();
|
||||
const payload = await urlData({ url, params });
|
||||
@@ -104,3 +109,19 @@ export function rewatchHistory() {
|
||||
watchHistory();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of history item IDs that are currently expanded in the history panel from the cache.
|
||||
* These content items need to retrieve detailed information when updated.
|
||||
* @returns {Array<string>} List of history item IDs that are currently expanded.
|
||||
*/
|
||||
function getCurrentlyExpandedHistoryContentIds() {
|
||||
const expandedItemIds = [];
|
||||
const cacheKey = "expanded-history-items";
|
||||
const expandedItems = loadSet(cacheKey);
|
||||
expandedItems.forEach((key) => {
|
||||
// Items have the format: <type>-<id>
|
||||
expandedItemIds.push(key.split("-")[1]);
|
||||
});
|
||||
return expandedItemIds;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user