v3: implement user and org sync queries

This commit is contained in:
Konstantin Haase 2015-03-31 17:02:07 +02:00
parent 841aaef368
commit 600aeabad9
3 changed files with 15 additions and 2 deletions

View File

@ -7,7 +7,9 @@ module Travis::API::V3
raise WrongParams, 'missing organization.id'.freeze
end
def sync
def sync(org = find)
user_query = Queries::User.new(params, main_type)
org.users.each { |user| user_query.sync(user) }
end
end
end

View File

@ -7,7 +7,11 @@ module Travis::API::V3
raise WrongParams, 'missing user.id'.freeze
end
def sync(user = find)
def sync(user = find, force: false)
return false if user.syncing? and not force
perform_async(:sync_user, user)
user.update_column(:is_syncing, true)
true
end
end
end

View File

@ -0,0 +1,7 @@
module Travis::API::V3
class Services::Organization::Sync < Service
def run!
query.sync if access_control.writable? find
end
end
end