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

Remove requested resources from included field #540

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 2 commits into django-json-api:master from hb9hnt:master
Jan 4, 2019

Conversation

Copy link
Contributor

@hb9hnt hb9hnt commented Jan 1, 2019

Fixes #524

Description of the Change

The resource(s) in the data field of the response are removed from the included_cache before building the included field for the response.

I added an integration test which checks whether this works on a single comment. If I request a comment and ask for all the comments of its associated blog entry with ?include=entry.comments all comments except the one which I requested should turn up in the included field.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added (I added a integration test since I couldn't figure out how to unit test this.)
  • documentation updated (couldn't find any relevant information on the documentation.
  • changelog entry added to CHANGELOG.md
  • author name in AUTHORS

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.

Thanks for working on this. The test looks good. In terms of implementation this should work this way. I am wondering though would it be possible to actually skip rendering the included data instead of deleting it at the end? This might be a slight performance improvement. What do you think?

If it makes the code more complex I am otherwise fine with how it is implemented right now.

Copy link
Contributor Author

hb9hnt commented Jan 3, 2019

We could add the actual resource to the included_cache and then remove it again later. However this introduces complexity and reduces performance for every request only to optimize performance for an edge case. After all it will rarely happen that the actual resource also turns up in the included field.

Copy link
Member

sliverc commented Jan 3, 2019

Fair point. Let's leave it this way.

Could you rebase to master and solve linting issue (see https://travis-ci.org/django-json-api/django-rest-framework-json-api/jobs/474761705)

Once this is done it is ready for merging.

Copy link

codecov bot commented Jan 3, 2019
edited
Loading

Codecov Report

Merging #540 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@
## master #540 +/- ##
==========================================
+ Coverage 95.51% 95.54% +0.03% 
==========================================
 Files 55 55 
 Lines 2829 2853 +24 
==========================================
+ Hits 2702 2726 +24 
 Misses 127 127
Impacted Files Coverage Δ
example/tests/conftest.py 100% <100%> (ø) ⬆️
rest_framework_json_api/renderers.py 87.01% <100%> (+0.48%) ⬆️
example/tests/integration/test_includes.py 100% <100%> (ø) ⬆️

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 55e8def...41872b1. Read the comment docs.

@sliverc sliverc changed the title (削除) Remove the requested resources from the included field (#524) (削除ここまで) (追記) Remove requested resources from included field (追記ここまで) Jan 4, 2019
@sliverc sliverc merged commit 517511f into django-json-api:master Jan 4, 2019
Copy link
Member

sliverc commented Jan 4, 2019

Merged. Thanks for your contribution.

Copy link
Contributor Author

hb9hnt commented Jan 4, 2019

Thanks for your help to fix this.

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.

2 participants

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