Skip to content

Improve condition handling#1587

Open
jochenklar wants to merge 4 commits into2.4.5/releasefrom
2.4.5/fix-conditions
Open

Improve condition handling#1587
jochenklar wants to merge 4 commits into2.4.5/releasefrom
2.4.5/fix-conditions

Conversation

@jochenklar
Copy link
Copy Markdown
Member

This PR improved the way conditions are checked in the interview. Instead of checked each element and set with a seperate request, the front end collects all checks into a list and sends as POST to a new resolve endpoint. Custom prefetching allows for very fast resolving.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 18, 2026

Coverage Status

coverage: 94.908% (+0.007%) from 94.901% — 2.4.5/fix-conditions into main

@jochenklar jochenklar changed the base branch from main to 2.4.5/release April 19, 2026 11:16
@jochenklar jochenklar added this to the RDMO 2.4.5 milestone Apr 19, 2026
@jochenklar jochenklar self-assigned this Apr 19, 2026
dispatch(resolveConditionInit())

return ProjectApi.resolveCondition(projectId, set, element)
return ProjectApi.resolveConditions(projectId, payload)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to early-return when payload.length === 0 to avoid an unnecessary API call?

}

export function resolveConditions(page, sets) {
const pendingId = 'resolveConditions'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that intentional? I’m wondering if overlapping resolveConditions calls could interfere with each other in pending tracking.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, me and my GPT assistant were also wondering about this, the static pendinId might make collision??

Generate a unique request id per resolveConditions() call, not a constant string.
2.
Dispatch that id in both addToPending() and removeFromPending().
3.
Carry the same id through resolveConditionsSuccess / resolveConditionsError and have the reducer ignore stale responses if a newer resolve has already started.
That solves both problems:

one completion no longer clears another in-flight request

an older response can’t overwrite newer condition state

const requestId = `resolveConditions/${Date.now()}/${Math.random()}`
dispatch(addToPending(requestId))
dispatch(resolveConditionsInit(requestId))
return ProjectApi.resolveConditions(...).then(
  (response) => {
    dispatch(removeFromPending(requestId))
    dispatch(resolveConditionsSuccess(requestId, response))
  }
)

Copy link
Copy Markdown
Member

@MyPyDavid MyPyDavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me it seems good, I also tested with the SMP (but it does not have many conditions on asingle page)

}

export function resolveConditions(page, sets) {
const pendingId = 'resolveConditions'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, me and my GPT assistant were also wondering about this, the static pendinId might make collision??

Generate a unique request id per resolveConditions() call, not a constant string.
2.
Dispatch that id in both addToPending() and removeFromPending().
3.
Carry the same id through resolveConditionsSuccess / resolveConditionsError and have the reducer ignore stale responses if a newer resolve has already started.
That solves both problems:

one completion no longer clears another in-flight request

an older response can’t overwrite newer condition state

const requestId = `resolveConditions/${Date.now()}/${Math.random()}`
dispatch(addToPending(requestId))
dispatch(resolveConditionsInit(requestId))
return ProjectApi.resolveConditions(...).then(
  (response) => {
    dispatch(removeFromPending(requestId))
    dispatch(resolveConditionsSuccess(requestId, response))
  }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants