Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Prefetch default included resources #900

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

Merged
sliverc merged 6 commits into django-json-api:master from SafaAlfulaij:fix-included-serializers
May 2, 2021
Merged

Prefetch default included resources #900

sliverc merged 6 commits into django-json-api:master from SafaAlfulaij:fix-included-serializers
May 2, 2021

Conversation

Copy link
Contributor

@SafaAlfulaij SafaAlfulaij commented Mar 28, 2021
edited by sliverc
Loading

Description of the Change

Pass the serializer to select_related and prefetch_related default included_resources. Without this, only resources specified by ?include are used.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

Copy link
Contributor Author

Sorry, but I have no idea why the test is failing.
I've never done tests.

Copy link
Member

sliverc commented Mar 31, 2021

Thanks for your contribution. PR number 900... wow! This is certainly a good addition to add support for default included resources. We might even consider this to be a bug that this has not been the case in the first place...

In terms of tests for quality assurance all PRs in DJA need to have a test to prove that the change actually does what it is supposed too.

It is never too late to start learning about testing though... for instance this is a good tutorial but there are many others out there.

It also seems with your change you discovered a potential another problem that inlcudes currently do not work when using relationship view. See failing test where a relationship view now prefetches default resources and fails.

Some more research needs to be done. If you think this is a bit too hard of a task we can also convert this PR to a issue report and somewhere else can have a look at it and have your PR as a reference.

Do you wanna give it or shot or shall we convert it to a bug report? What do you think?

Copy link
Contributor Author

I'm not sure if the test environment is different than the normal environment, but /entries?fields[entry]=comments&page[size]=25 executes exactly 3 queries. I don't know why the test environment ignores fields[entry]=comments.

Anyway, this is the best I can reach in testing. If anyone is willing to do more, please feel free to take over.

Copy link
Contributor Author

So the tests use the plural (normal I believe) form of resources, while the end-user example uses the singular form.
Should be fixed now.

Copy link

codecov bot commented Apr 3, 2021
edited
Loading

Codecov Report

Merging #900 (74d2a17) into master (a5df955) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@
## master #900 +/- ##
=======================================
 Coverage 97.68% 97.69% 
=======================================
 Files 58 58 
 Lines 3115 3120 +5 
=======================================
+ Hits 3043 3048 +5 
 Misses 72 72 
Impacted Files Coverage Δ
example/tests/test_performance.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5df955...74d2a17. Read the comment docs.

Copy link
Member

sliverc commented Apr 27, 2021

@SafaAlfulaij As of changes merged in #914 could you rebase this to master?

Copy link

It seems that this is the only issue preventing #911. I can free up sometime this coming Wednesday to look at rebasing this to master if that helps?

Copy link
Member

sliverc commented May 2, 2021

@simkimsia Thanks for your offer. Really appreciated. I got around today to look at this PR and hope a new version of DJA will be out soon.

simkimsia reacted with thumbs up emoji

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

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

@SafaAlfulaij I made some small adjustment and the PR is now ready for merging. Thanks for your work!

SafaAlfulaij reacted with thumbs up emoji
@sliverc sliverc changed the title (削除) Prefetch default resources (削除ここまで) (追記) Prefetch default included resources (追記ここまで) May 2, 2021
@sliverc sliverc merged commit fbb4b03 into django-json-api:master May 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@sliverc sliverc sliverc approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /