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

Optimize indexation #1215

Merged
merged 1 commit into from Oct 18, 2017
Merged

Optimize indexation #1215

merged 1 commit into from Oct 18, 2017

Conversation

noirbizarre
Copy link
Contributor

This PR optimize indexation by:

  • removing some field that weren't in use (ex: user.role)
  • turning off the automatic derefencing while iterating over objects to only fetch what's necessary

CHANGELOG.md Outdated
@@ -22,6 +22,7 @@
- Switch from static theme avatars/placeholders to [identicons](https://en.wikipedia.org/wiki/Identicon) for readability (mostly on discussions) [#1193](https://github.com/opendatateam/udata/pull/1193)
- Fix the scroll to a discussion sub-thread [#1206](https://github.com/opendatateam/udata/pull/1206)
- Fix duplication in discussions [migration] [#1209](https://github.com/opendatateam/udata/pull/1209)
- Optimize a little bit indexation [#1215](https://github.com/opendatateam/udata/pull/1215)
Copy link
Contributor

Choose a reason for hiding this comment

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

*Optimize indexation a little bit

else:
organization = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe initialize organization, owner and image_url to None before the ifs? If feel more comfortable with this pattern but YMMV.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, it's much better


document = {
'title': dataset.title,
'description': dataset.description,
'license': (dataset.license.id
if dataset.license is not None else None),
'license': getattr(dataset.license, 'id', None),
Copy link
Contributor

Choose a reason for hiding this comment

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

👌

owner = User.objects(id=reuse.owner.id).first()
organization = None
else:
organization = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Same remark as above about initialization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@noirbizarre noirbizarre merged commit 0a1c266 into opendatateam:master Oct 18, 2017
@noirbizarre noirbizarre deleted the tune-indexation branch October 18, 2017 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants