Skip to content

plan/edit: produce less queries#2861

Merged
briri merged 5 commits intoDMPRoadmap:developmentfrom
nicolasfranck:pr_plan_edit_less_queries
Apr 18, 2021
Merged

plan/edit: produce less queries#2861
briri merged 5 commits intoDMPRoadmap:developmentfrom
nicolasfranck:pr_plan_edit_less_queries

Conversation

@nicolasfranck
Copy link
Contributor

Changes proposed in this PR:

  • add relations question_format question_options annotations themes to list of include in PlansController
  • remove include in Section#answered_questions, because already done by PlansController and because it breaks the chain of relations
  • replace where and order by select and sort in model Question because it reexecutes the queries instead of using the relations
  • Optimize GuidancePresenter#guidance_groups_by_theme
  • Optimize ConditionsHelper

You should see less queries in the log when opening the tab "Write plan"

P.S. Is ConditionsHelper#num_section_questions still expected to receive section and phase as hashes, or is this kept for backward compatibility for those who are branding their views?

Copy link
Contributor

@briri briri left a comment

Choose a reason for hiding this comment

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

thanks for this refactor @nicolasfranck

def edit
plan = Plan.includes({ template: { phases: { sections: :questions } } }, { answers: :notes })
plan = Plan.includes(
{ template: {
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for formatting this, it's much easier to read this way

@briri briri merged commit 90acb9e into DMPRoadmap:development Apr 18, 2021
portagenetwork pushed a commit to portagenetwork/roadmap that referenced this pull request Feb 24, 2022
…ss_queries

plan/edit: produce less queries
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.

2 participants