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 reconstructing attributes in #revisions #403

Merged
merged 1 commit into from
Jan 31, 2018

Conversation

fatkodima
Copy link
Contributor

Follow up of #402.

Also replaced .empty? with .exists?, because for older rails'es (at least for 4.0.0) .empty? is implemented through COUNT, instead of through SELECT 1 like in new versions.

Copy link
Collaborator

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Sorry for the delay - Just a small comment inline, and could you please also add a line to the Changelog?

revision_with(reconstruct_attributes(ancestors).merge(version: audit.version))
revision_attributes = previous_attributes.merge(audit.new_attributes)
previous_attributes = revision_attributes
revision_with(revision_attributes.merge!(version: audit.version))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you don't actually need the extra variable here, maybe something like:

previous_attributes.merge!(audit.new_attributes)
revision_with(previous_attributes.merge!(version: audit.version))

@fatkodima
Copy link
Contributor Author

Updated this. Failing tests are not related to my changes. I fixed them in a separate PR.

Copy link
Collaborator

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Thanks @fatkodima !

@tbrisker tbrisker merged commit 114a089 into collectiveidea:master Jan 31, 2018
@fatkodima fatkodima deleted the optimize-revisions-hashes branch January 31, 2018 20:19
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

2 participants