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

[RFC] Performance improvements: Answer visibility denormalisation #2324

Open
winged opened this issue Nov 7, 2024 · 0 comments
Open

[RFC] Performance improvements: Answer visibility denormalisation #2324

winged opened this issue Nov 7, 2024 · 0 comments

Comments

@winged
Copy link
Contributor

winged commented Nov 7, 2024

When validating documents and answers, often we need to verify that all answers are valid (ever answer where is_required evaluates to True must be filled in, for example)

Now in complex structures, this becomes rather complex, as things like dynamic options, data sources etc come into play.

Proposal

We need to cache locally the resulting value of is_hidden and is_required in answers, as well as is_hidden in options.

To do this, I propose a similar structure to what we already have in the calculated questions: We start with a list of question slugs mentioned in the JEXL expressions. These questions then get a forward reference to our question with the expression.

Each time an answer with such a question is saved, we look for "dependent" answers and invalidate their is_hidden and is_required state, as well as their options' is_hidden if it's a [multiple]choice question.

The document/answer validator then checks the cached values instead of evaluating the JEXL every time:

  • if it's None, recalculate and save the result to database
  • if it's True or False, no recalculation required, just use the value as-is.
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

No branches or pull requests

1 participant