Permalink
Browse files

fix export script

  • Loading branch information...
1 parent 0091fe6 commit b88e514ba45c86744f264a1849d648aa832c2184 @patcito patcito committed Dec 20, 2011
Showing with 12 additions and 5 deletions.
  1. +8 −0 app/models/group.rb
  2. +4 −5 script/export
View
@@ -161,6 +161,14 @@ class Group
before_create :set_default_theme
after_create :create_default_tags
+ # use for export script, slow
+ def members(only=nil)
+ fields = [:user_id]
+ fields << only if only
+ ids = self.memberships.only(fields).map(&:user_id)
+ users = User.where(:_id.in => ids)
+ end
+
# TODO: store this variable
def has_custom_domain?
@has_custom_domain ||= self[:domain].to_s !~ /#{AppConfig.domain}/
View
@@ -49,11 +49,11 @@ if options[:method] == :zip
exporter.to_zip(Question, zf)
exporter.to_zip(Answer, zf)
exporter.to_zip(Badge, zf)
- exporter.to_zip(Ad, zf)
exporter.to_zip(User, zf, :selector => {:"membership_list.#{group.id}" => {:$exists => true}},
:except => exclude)
- friend_list_ids = group.members.only(:friend_list_id).map(&:friend_list_id)
- exporter.to_file(FriendList, :selector => {:_id.in => friend_list_ids})
+ friend_list_ids = group.members(:friend_list_id).map(&:friend_list_id)
+ puts friend_list_ids
+ exporter.to_file(FriendList, :selector => {:_id => friend_list_ids})
end
else
FileUtils.mkpath(group.subdomain)
@@ -65,10 +65,9 @@ else
exporter.to_file(Question)
exporter.to_file(Answer)
exporter.to_file(Badge)
- exporter.to_file(Ad)
exporter.to_file(User, :selector => {"membership_list.#{group.id}" => {:$exists => true}},
:except => exclude)
- friend_list_ids = group.members.only(:friend_list_id).map(&:friend_list_id)
+ friend_list_ids = group.members(:friend_list_id).map(&:friend_list_id)
exporter.to_file(FriendList, :selector => {:_id.in => friend_list_ids})
end

0 comments on commit b88e514

Please sign in to comment.