-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support return repos_count and origin on latest metrics API (#10)
Signed-off-by: EdmondFrank <[email protected]>
- Loading branch information
1 parent
462981f
commit de64767
Showing
5 changed files
with
63 additions
and
24 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Director | ||
include Common | ||
|
||
COMMUNITY_CACHE_KEY = 'compass-community-list' | ||
|
||
def director_repo_list(remote_url) | ||
begin | ||
Rails.cache.fetch("#{COMMUNITY_CACHE_KEY}-#{__method__}-#{remote_url}-list", expires_in: 15.minutes) do | ||
encode_url = URI.encode_www_form_component(remote_url) | ||
response = | ||
Faraday.get( | ||
"#{CELERY_SERVER}/api/compass/#{encode_url}/repositories", | ||
{ 'Content-Type' => 'application/json' } | ||
) | ||
repo_resp = JSON.parse(response.body) | ||
repo_resp.inject([]) do |sum, (_, resource)| | ||
sum + resource.map { |_, list| list } | ||
end.flatten.uniq | ||
end | ||
rescue => ex | ||
Rails.logger.error("failed to retrive repositories, error: #{ex.message}") | ||
[] | ||
end | ||
end | ||
end |
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
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
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
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