48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/furik/cli.rb', line 48
def activity
from = Date.parse(options[:from])
to = Date.parse(options[:to])
since = options[:since]
diff = (to - from).to_i
diff.zero? ? from -= since : since = diff
period = case since
when 999 then 'All'
when 0 then "Today's"
else "#{since + 1}days"
end
puts "#{period} Activities"
puts '-'
puts ''
Furik.events_with_grouping(gh: options[:gh], ghe: options[:ghe], from: from, to: to) do |repo, events|
puts "### #{repo}"
puts ''
events.sort_by(&:type).reverse.each_with_object({ keys: [] }) do |event, memo|
payload_type = event.type.
gsub('Event', '').
gsub(/.*Comment/, 'Comment').
gsub('Issues', 'Issue').
underscore
payload = event.payload.send(:"#{payload_type}")
type = payload_type.dup
title = case event.type
when 'IssueCommentEvent'
"#{payload.body.plain.cut} (#{event.payload.issue.title.cut(30)})"
when 'CommitCommentEvent'
payload.body.plain.cut
when 'IssuesEvent'
type = "#{event.payload.action}_#{type}"
payload.title.plain.cut
when 'PullRequestReviewCommentEvent'
type = 'comment'
if event.payload.pull_request.respond_to?(:title)
"#{payload.body.plain.cut} (#{event.payload.pull_request.title.cut(30)})"
else
payload.body.plain.cut
end
else
payload.title.plain.cut
end
link = payload.html_url
key = "#{type}-#{link}"
next if memo[:keys].include?(key)
memo[:keys] << key
puts "- [#{type}](#{link}): #{title}"
end
puts ''
end
end
|