Permalink
Browse files

get the last change of app polished

  • Loading branch information...
1 parent a688b35 commit ae44651c60cc2764997b6170bbf90459e8de2141 @mkristian committed Jun 11, 2013
View
2 app/controllers/remote/domains_controller.rb
@@ -8,7 +8,7 @@ def last_changes
# GET /domains/last_changes_of_app
def last_changes_of_app
- @domains = Domain.all_changed_after_for_app( params[ :updated_at ], remote_permission )
+ @domains = Domain.all_changed_after_of_app( params[ :updated_at ], remote_permission )
respond_with serializer( @domains ).use( :update )
end
View
2 app/controllers/remote/users_controller.rb
@@ -8,7 +8,7 @@ def last_changes
# GET /users/last_changes_of_app
def last_changes_of_app
- @users = User.all_changed_after_for_app( params[ :updated_at ], remote_permission )
+ @users = User.all_changed_after_of_app( params[ :updated_at ], remote_permission )
respond_with serializer( @users ).use( :for_app )
end
View
11 app/models/domain.rb
@@ -14,14 +14,15 @@ def self.all_changed_after( from )
end
end
- def self.all_changed_after_for_app( from, app )
- unless from.blank?
- DomainsGroupsUser.uniq.joins( :group => :application ).where( 'application_id = ? and users.updated_at > ?',
- app.id,
- from )
+ def self.all_changed_after_of_app( from, app )
+ set = unless from.blank?
+ DomainsGroupsUser.joins( :group, :domain ).where( 'application_id = ? and domains.updated_at > ?',
+ app.id,
+ from )
else
DomainsGroupsUser.uniq.joins( :group => :application ).where( 'application_id = ?',
app.id )
end
+ set.collect { |d| d.domain }.uniq
end
end
View
2 app/models/user.rb
@@ -258,7 +258,7 @@ def reset_password_and_save
end
end
- def self.all_changed_after_for_app( from, app )
+ def self.all_changed_after_of_app( from, app )
unless from.blank?
User.uniq.joins( :groups => :application ).where( 'application_id = ? and users.updated_at > ?',
app.id,
View
4 config/routes.rb
@@ -4,10 +4,10 @@
get '/applications/last_changes', :controller => 'remote/applications', :action => :last_changes
get '/regions/last_changes', :controller => 'remote/regions', :action => :last_changes
get '/users/last_changes', :controller => 'remote/users', :action => :last_changes
- get '/users/last_changes_for_app', :controller => 'remote/users', :action => :last_changes_for_app
+ get '/users/last_changes_of_app', :controller => 'remote/users', :action => :last_changes_of_app
put '/users/setup', :controller => 'remote/users', :action => :setup
get '/domains/last_changes', :controller => 'remote/domains', :action => :last_changes
- get '/domains/last_changes_for_app', :controller => 'remote/domains', :action => :last_changes_for_app
+ get '/domains/last_changes_of_app', :controller => 'remote/domains', :action => :last_changes_of_app
post '/authentications', :controller => 'remote/authentications', :action => :create
post '/authentications/reset_password', :controller => 'remote/authentications', :action => :reset_password

0 comments on commit ae44651

Please sign in to comment.