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

Fixed parent orgs not updating children orgs [#135366883] #802

Merged
merged 2 commits into from
Dec 9, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def update

def update_organization
@attributes.delete(:id)
name_change = @attributes[:name] != @organization.name
name_change = @attributes[:name] != @organization.name || @attributes[:abbreviation] != @organization.abbreviation
if @organization.update_attributes(@attributes)
@organization.update_ssr_org_name if name_change
@organization.update_descendants_availability(@attributes[:is_available])
Expand Down
1 change: 1 addition & 0 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def process_ssrs_parent
end

def update_ssr_org_name
self.org_children.each{ |org| org.update_ssr_org_name }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can do this a little more efficiently. I think this would do the same thing as both lines.

SubServiceRequest.where(organization: self.all_child_organizations).each(:&update_org_tree)

Copy link
Contributor

Choose a reason for hiding this comment

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

all_child_organizations will fetch every descendant of self, while org_children only returns immediate children. @BigChiefSmidgeums which should it be?

self.sub_service_requests.each{ |ssr| ssr.update_org_tree }
end

Expand Down