-
-
Save g5codyswartz/0f05cf42428d69c7a66a to your computer and use it in GitHub Desktop.
Output an array of widget names & locations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrphanAnnie | |
def self.perform | |
lost_souls = mom_is_that_you | |
write_to_loggers("#{lost_souls}") | |
end | |
def self.mom_is_that_you | |
names = Widget.orphans.select {|i| !i.parent_widget.nil?} | |
web_pages = names.map {|w| | |
self.get_infos(w) | |
} | |
end | |
def self.get_infos(widget) | |
loc = Location.find(widget.parent_widget.web_template.website.owner_id) | |
[widget.id.to_s+": "+widget.name, | |
widget.parent_widget.id.to_s+": "+widget.parent_widget.name+" | Web Template ID: "+widget.parent_widget.web_template_id.to_s, | |
widget.parent_widget.parent_widget.id.to_s+": "+widget.parent_widget.parent_widget.name+" | Web Template ID: "+widget.parent_widget.parent_widget.web_template_id.to_s, | |
widget.parent_widget.web_template.name, | |
loc.name+" | Internal Name: "+loc.internal_branded_name] | |
end | |
def self.self_adoption(lost_id) | |
orphan = Widget.find(lost_id) | |
self.adopt_parent(lost_id, orphan.parent_widget_id) | |
end | |
def self.adopt_parent(lost_id, parent_id) | |
orphan = Widget.find(lost_id) | |
parent = Widget.find(parent_id) | |
self.update_web_template_id(orphan, parent.web_template_id) | |
end | |
def self.update_web_template_id(orphan, web_template_id) | |
orphan.update_attributes({web_template_id: web_template_id}) | |
end | |
def self.auto_self_adopt | |
Widget.orphans.select {|i| !i.parent_widget.nil?}.each { |w| self.self_adoption(w.id) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment