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

use script id to find teacher feedback script level #38729

Merged
merged 4 commits into from Feb 1, 2021

Conversation

davidsbailey
Copy link
Member

@davidsbailey davidsbailey commented Jan 26, 2021

FInishes PLAT-685. See migrating teacher feedback ids for more context.

It turns out the only place we were using TeacherFeedback.script_level was on the studio.code.org/feedback page. This PR updates that codepath to use script id instead of script level id, and adds a bit of test coverage.

Testing story

  • Added test coverage which counts queries for multiple feedbacks on /feedback
  • improved existing test cases to make sure the feedback data reached the client
  • manually verified that /feedback is still working for students

Future work

When viewing the script level page, we should show only feedback for that script. today, we show any feedback on that level in any script. This work is being tracked by learning platform (see slack).

Reviewer Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@davidsbailey davidsbailey changed the base branch from staging to require-feedback-script-id January 26, 2021 16:52
@@ -6,14 +6,23 @@ class TeacherFeedbacksController < ApplicationController
# Feedback from any verified teacher who has provided feedback to the current
# student on any level
def index
@feedbacks_as_student = @teacher_feedbacks.order(created_at: :desc).includes(script_level: {lesson: :script}).select do |feedback|
scope = {
Copy link
Contributor

Choose a reason for hiding this comment

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

@davidsbailey Can you point me to a good place to read about this?

Copy link
Member Author

Choose a reason for hiding this comment

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

the effect of passing this to includes can be read about briefly here: https://api.rubyonrails.org/v6.1.1/classes/ActiveRecord/QueryMethods.html#method-i-includes the short version is that this syntax tells it which associated models to load, so that (in this case) when I call feedback.level.script_levels, no additional DB queries are needed. (the other nested fields are used by summary_for_feedback)

There are a few blog posts that go into way more detail about all the stuff that rails is doing behind the scenes when you use includes or other similar methods: https://bigbinary.com/blog/preload-vs-eager-load-vs-joins-vs-includes

@davidsbailey davidsbailey marked this pull request as ready for review January 26, 2021 17:45
Copy link
Contributor

@Erin007 Erin007 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 adding the tests! LGTM

Base automatically changed from require-feedback-script-id to staging January 27, 2021 19:33
@davidsbailey davidsbailey merged commit 862b985 into staging Feb 1, 2021
@davidsbailey davidsbailey deleted the use-feedback-script-id branch February 1, 2021 22:28
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.

None yet

3 participants