Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rerendering cluster names #769

Merged
merged 11 commits into from
Jul 14, 2022
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());
aerlaut marked this conversation as resolved.
Show resolved Hide resolved
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