summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2016-07-13 20:07:09 +0200
committerVarac <varac@leap.se>2017-10-16 13:20:14 +0200
commit11d443664b7a785b42cbbd5b96347bafa5ad273a (patch)
tree9a27d4c1fe58e3375ae1868cf7a29da1af106265 /lib
parentfa7cf47e28a4ac1636e947c269ed83abe49a1491 (diff)
initial commit, import from pixelated_dashboard
Diffstat (limited to 'lib')
-rw-r--r--lib/ccmenu.rb57
-rw-r--r--lib/github.rb123
-rw-r--r--lib/weekly_goals.rb22
3 files changed, 202 insertions, 0 deletions
diff --git a/lib/ccmenu.rb b/lib/ccmenu.rb
new file mode 100644
index 0000000..90257f5
--- /dev/null
+++ b/lib/ccmenu.rb
@@ -0,0 +1,57 @@
+require 'crack'
+require 'open-uri'
+require 'json'
+
+class CCMenu
+
+ def initialize(url)
+ @data = Crack::XML.parse(open(url))['Projects']['Project']
+ @data=@data.select{ |i| i['name'][/^[^\:\:]*\:\:[^\:\:]*$/]}
+ puts @data
+ end
+
+ def json
+ @data.to_json
+ end
+
+ def status
+ overall = 'Success'
+ @data.each do |step|
+ if step['lastBuildStatus'] != 'Success'
+ overall = step['lastBuildStatus']
+ end
+ end
+ return overall
+ end
+ def failed
+ list = Array.new
+ @data.each do |step|
+ puts step
+ list << step['name'] if step['lastBuildStatus'] == 'Failure'
+ end
+ return list
+ end
+
+ def num_total
+ @data.length
+ end
+
+ def num_failed
+ self.failed.length
+ end
+
+ def color
+ case status
+ when 'Failure' then 'red'
+ when 'Exception' then 'orange'
+ when 'Unknown' then 'orange'
+ else 'green'
+ end
+ end
+
+
+ def data
+ @data
+ end
+
+end
diff --git a/lib/github.rb b/lib/github.rb
new file mode 100644
index 0000000..77d765e
--- /dev/null
+++ b/lib/github.rb
@@ -0,0 +1,123 @@
+require 'date'
+require 'open-uri'
+require 'json'
+
+class Github
+
+ def initialize(orgname)
+ url='https://api.github.com/orgs/'+orgname
+ @headers={'User-Agent' => 'LEAP Dashboard'}
+ if ENV.has_key?('GITHUB_AUTH_TOKEN')
+ @headers['Authorization'] = "token "+ENV['GITHUB_AUTH_TOKEN']
+ end
+ @org=JSON.parse(open(url,@headers).read)
+ @repos=JSON.parse(open(@org['repos_url'],@headers).read)
+ end
+
+ def repocount
+ @repos.count
+ end
+
+ def prcount
+ count=0
+ @repos.each do |r|
+ count+=JSON.parse(open(r['url']+'/pulls',@headers).read).count
+ end
+ return count
+ end
+
+ def recent_open_issues
+ count=0
+ @repos.each do |r|
+ url=r['url']+'/issues?state=open&since='+(Time.new().to_datetime << 1).to_time.strftime("%Y-%m-%dT%H:%M:%SZ")
+ count+=JSON.parse(open(url,@headers).read).count
+ end
+ return count
+ end
+ def recent_issues
+ count=0
+ @repos.each do |r|
+ url=r['url']+'/issues?state=all&since='+(Time.new().to_datetime << 1).to_time.strftime("%Y-%m-%dT%H:%M:%SZ")
+ count+=JSON.parse(open(url,@headers).read).count
+ end
+ return count
+ end
+ def open_pull_requests
+ count=0
+ @repos.each do |r|
+ url=r['url']+'/pulls?state=open'
+ count+=JSON.parse(open(url,@headers).read).count
+ end
+ return count
+ end
+ def pull_requests
+ count=0
+ @repos.each do |r|
+ url=r['url']+'/pulls?state=all'
+ count+=JSON.parse(open(url,@headers).read).count
+ end
+ return count
+ end
+ def forks
+ count=0
+ @repos.each do |r|
+ url=r['url']+'/forks'
+ count+=JSON.parse(open(url,@headers).read).count
+ end
+ return count
+ end
+ def issues_in_development
+ count=0
+ @repos.each do |r|
+ url=r['url']+'/issues?labels=2%20-%20Development'
+ count+=JSON.parse(open(url,@headers).read).count
+ end
+ return count
+ end
+ def prlist
+ prlist=[]
+ @repos.each do |r|
+ JSON.parse(open(r['url']+'/pulls',@headers).read).each do |pr|
+ prlist<<{'label'=>pr['title'], 'pr_url'=>pr['html_url']}
+ end
+ end
+ return prlist
+ end
+
+ def stargazers
+ @repos.inject(0) {|sum,hash| sum + hash['stargazers_count']}
+ end
+ def epic_issues
+ count=0
+ @repos.each do |r|
+ url=r['url']+'/issues?labels=UA%20multiuser'
+ count+=JSON.parse(open(url,@headers).read).count
+ end
+ return count
+ end
+ def all_epic_issues
+ count=0
+ @repos.each do |r|
+ url=r['url']+'/issues?labels=UA%20multiuser&state=all'
+ count+=JSON.parse(open(url,@headers).read).count
+ end
+ return count
+ end
+
+ def action_items
+ issues=[]
+ @repos.each do |r|
+ url=r['url']+'/issues?labels=Action+item'
+ JSON.parse(open(url,@headers).read).each do |issue|
+ title=issue['title']
+ if issue.has_key?('assignee') and not issue['assignee'].nil?
+ assignee=issue['assignee']['login']
+ else
+ assignee='None'
+ end
+ issues<<{'label' => title, 'value' => assignee}
+ end
+ end
+ issues
+ end
+end
diff --git a/lib/weekly_goals.rb b/lib/weekly_goals.rb
new file mode 100644
index 0000000..1a263bc
--- /dev/null
+++ b/lib/weekly_goals.rb
@@ -0,0 +1,22 @@
+require 'time'
+
+class WeeklyGoals
+ def initialize
+ @goals = [
+ "Remove docker: Finish the load test report comparing the new and the old archicteture",
+ "Modularize stylesheet: ",
+ "Fix bug: Error running functionals on vagrant",
+ "Fix bug: Fix Feedback Form",
+ "Fix bug: Minify JS"]
+ end
+
+ def rotating_goal
+ min = Time.new.min
+ idx = min % @goals.length
+ @goals[idx]
+ end
+
+ def all_goals
+ @goals
+ end
+end