Skip to content

Commit

Permalink
Merge pull request #769 from hms-dbmi-cellenics/rerendering-cluster-n…
Browse files Browse the repository at this point in the history
…ames

Update cached plots when cluster names change.
  • Loading branch information
Kristian-A authored Jul 14, 2022
2 parents 0bbf8bb + 7e3d585 commit 6a6f371
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`Generate plot work request body Generates the correct work request body for DotPlot 1`] = `
Object {
"clusterNames": undefined,
"customGenesList": Array [],
"filterBy": Object {
"group": "All",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const DotPlotPage = (props) => {
} = useSelector((state) => state.genes.properties.views[plotUuid] || {});

const cellSets = useSelector(getCellSets());

const {
loading: cellSetsLoading,
error: cellSetsError,
Expand Down
24 changes: 22 additions & 2 deletions src/redux/actions/componentConfig/fetchPlotDataWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,30 @@ import endUserMessages from 'utils/endUserMessages';
import generatePlotWorkBody from 'utils/work/generatePlotWorkBody';
import { fetchWork } from 'utils/work/fetchWork';

const fetchPlotDataWork = (experimentId, plotUuid, plotType) => async (dispatch, getState) => {
const config = getState().componentConfig[plotUuid]?.config ?? initialPlotConfigStates[plotType];
const getClusterNames = (state) => {
const clusterIds = state.cellSets.hierarchy.reduce(
(acc, cellSet) => [...acc, ...cellSet.children.map((entry) => entry.key)],
[],
);

const clusterNames = clusterIds?.map((clusterId) => state.cellSets.properties[clusterId].name);
return clusterNames;
};

const fetchPlotDataWork = (
experimentId,
plotUuid,
plotType,
) => async (dispatch, getState) => {
let config = getState().componentConfig[plotUuid]?.config ?? initialPlotConfigStates[plotType];
const clusterNames = getClusterNames(getState());
const timeout = getTimeoutForWorkerTask(getState(), 'PlotData');

config = {
...config,
clusterNames,
};

try {
const body = generatePlotWorkBody(plotType, config);

Expand Down
13 changes: 11 additions & 2 deletions src/utils/work/fetchWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ const fetchWork = async (
getState,
optionals = {},
) => {
const { extras = undefined, timeout = 180, broadcast = false } = optionals;
const {
extras = undefined,
timeout = 180,
broadcast = false,
} = optionals;

const backendStatus = getBackendStatus(experimentId)(getState()).status;

const { environment } = getState().networkResources;
Expand Down Expand Up @@ -135,7 +140,11 @@ const fetchWork = async (
}

const ETag = createObjectHash({
experimentId, body, qcPipelineStartDate, extras, cacheUniquenessKey,
experimentId,
body,
qcPipelineStartDate,
extras,
cacheUniquenessKey,
});

// First, let's try to fetch this information from the local cache.
Expand Down
2 changes: 2 additions & 0 deletions src/utils/work/generatePlotWorkBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const composeDotPlotWorkBody = (config) => {
group: filterGroup,
key: filterKey || 'All',
},
// clusterNames is used for triggering a work request upon cluster name change
clusterNames: config.clusterNames,
};
};

Expand Down

0 comments on commit 6a6f371

Please sign in to comment.