This is an automated email from the ASF dual-hosted git repository.
rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new e3d5797 refactor logic into a common library
e3d5797 is described below
commit e3d5797d44db97877037d0c208400dadbf6ef9f0
Author: Sam Ruby <[email protected]>
AuthorDate: Tue Jun 6 08:59:12 2017 -0400
refactor logic into a common library
---
lib/whimsy/asf/podlings.rb | 30 ++++++++++++++++++++++++++++++
www/board/agenda/routes.rb | 20 +-------------------
2 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/lib/whimsy/asf/podlings.rb b/lib/whimsy/asf/podlings.rb
index 1db36a3..8a4a1ca 100644
--- a/lib/whimsy/asf/podlings.rb
+++ b/lib/whimsy/asf/podlings.rb
@@ -233,6 +233,36 @@ module ASF
hash
end
+ # parse (and cache) names mentioned in podlingnamesearches
+ def self.namesearch
+ # cache JIRA response
+ cache = "#{ASF::Config.get(:cache)}/pns.jira"
+ if not File.exist?(cache) or File.mtime(cache) > Time.now - 300
+ query = 'https://issues.apache.org/jira/rest/api/2/search?' +
+ 'jql=project=PODLINGNAMESEARCH&fields=summary,resolution'
+ File.write cache, Net::HTTP.get(URI(query))
+ end
+
+ # parse JIRA titles for proposed name
+ issues = JSON.parse(File.read(cache))['issues'].map do |issue|
+ title = issue['fields']['summary']
+ name = title[/"Apache ([A-Z].*?)"/, 1]
+ name ||= title[/'Apache ([A-Z].*?)'/, 1]
+ name ||= title[/.*Apache ([A-Z]\S*)/, 1]
+ name ||= title.gsub('Apache', '')[/.*\b([A-Z]\S*)/, 1]
+ next unless name
+ resolution = issue['fields']['resolution']
+ resolution = resolution ? resolution['name'] : 'Unresolved'
+ [name, {issue: issue['key'], resolution: resolution}]
+ end
+
+ issues.sort.to_h
+ end
+
+ # return podlingnamesearch for this podling
+ def namesearch
+ Podling.namesearch[display_name]
+ end
end
# more backwards compatibility
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index 945355e..452c1d2 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -185,25 +185,7 @@ end
# podling name searches
get '/json/podlingnamesearch' do
-
- query = 'https://issues.apache.org/jira/rest/api/2/search?' +
- 'jql=project=PODLINGNAMESEARCH&fields=summary,resolution'
-
- issues = JSON.parse(Net::HTTP.get URI(query))['issues']
-
- issues.map! do |issue|
- title = issue['fields']['summary']
- name = title[/"Apache ([A-Z].*?)"/, 1]
- name ||= title[/'Apache ([A-Z].*?)'/, 1]
- name ||= title[/.*Apache ([A-Z]\S*)/, 1]
- name ||= title.gsub('Apache', '')[/.*\b([A-Z]\S*)/, 1]
- next unless name
- resolution = issue['fields']['resolution']
- resolution = resolution ? resolution['name'] : 'Unresolved'
- [name, {issue: issue['key'], resolution: resolution}]
- end
-
- _json issues.compact.sort.to_h
+ _json ASF::Podling.namesearch
end
# posted actions
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].