-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do stats collection from Netlify in aggregate #13
Open
kingdonb
wants to merge
1
commit into
fluxcd:main
Choose a base branch
from
kingdonb:collect-stats
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 @@ | ||
ruby '2.7.6' | ||
source 'https://rubygems.org' | ||
|
||
gem 'awesome_print', require: 'ap' | ||
gem 'activesupport' | ||
gem 'pry' |
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,34 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
activesupport (7.0.2.3) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (>= 1.6, < 2) | ||
minitest (>= 5.1) | ||
tzinfo (~> 2.0) | ||
awesome_print (1.9.2) | ||
coderay (1.1.3) | ||
concurrent-ruby (1.1.10) | ||
i18n (1.10.0) | ||
concurrent-ruby (~> 1.0) | ||
method_source (1.0.0) | ||
minitest (5.15.0) | ||
pry (0.14.1) | ||
coderay (~> 1.1) | ||
method_source (~> 1.0) | ||
tzinfo (2.0.4) | ||
concurrent-ruby (~> 1.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
activesupport | ||
awesome_print | ||
pry | ||
|
||
RUBY VERSION | ||
ruby 2.7.6p219 | ||
|
||
BUNDLED WITH | ||
2.1.4 |
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,57 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'ap' | ||
require 'pry' | ||
|
||
require 'active_support/all' | ||
|
||
# commits_so_far = %w{03d50caa 18b2d4d6 b71353a4 62624387 128d3da5 e267f767 0773e5cf cb3feaa3 1bfa4c4e dd14c72e 1999ff43 aa3b4887 56625329 458602ad 036a5aff 8b877e28 1d51457c 3be3dc1b dbab09f2 373007bf d3c74fc6 f9b1515c 32310e84 5afe9a0a bc0c9a1f 30af67db b5b73107 79d4dce9 9a7205c9 dc38f527 0c4cd32b ec00ee72 76f446e2 73bd5f3c 23d2fcb0 2faf6f45 fe008045 3f112981 c7ac014a 97e183ce 0d062e6e f1cef3ee 92ff87e4} | ||
|
||
commits_so_far = `git log main..netlify-stats --oneline --reverse |awk '{print $1}'|grep -v 17353663`.split("\n") | ||
|
||
def fetch_from_commit(commit_hash) | ||
`git co #{commit_hash}` | ||
pages = File.open('pages.csv') | ||
ret = {} | ||
pages.lines.each do |line| | ||
v = line.chomp.split(',') | ||
ret[v.first] = v.last.to_i | ||
end | ||
|
||
ret | ||
end | ||
|
||
stats = commits_so_far.map do |c| | ||
f = fetch_from_commit(c) | ||
# binding.pry | ||
f | ||
end | ||
|
||
all_stats = {} | ||
days_counted = 0 | ||
|
||
stats.each do |stat| | ||
stat.keys.each do |key| | ||
if all_stats[key].nil? | ||
all_stats[key] = 0 | ||
end | ||
|
||
all_stats[key] += stat[key] | ||
end | ||
|
||
days_counted += 1 | ||
end | ||
|
||
puts; puts | ||
|
||
o_hash = ActiveSupport::OrderedHash.new | ||
|
||
ordered_stats = all_stats.sort_by(&:last).reverse | ||
ordered_stats.map do |n| | ||
o_hash[n[0]] = n[1] | ||
# puts "#{n[0]}: #{n[1]}" | ||
end | ||
|
||
ap o_hash | ||
puts; puts '---' | ||
puts "days_counted: #{days_counted}" |
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,8 @@ | ||
#!/usr/bin/env sh | ||
|
||
git checkout netlify-stats && git pull --ff-only | ||
git checkout main && git pull --ff-only | ||
|
||
bundle exec --gemfile collect-stats/Gemfile collect-stats/collect-stats.rb | ||
|
||
git checkout main |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're testing and this hasn't been merged yet, you'll want to run this
bundle exec
command instead of the script (as it won't be present in the main branch yet)It does a bunch of
git checkout
stuff and branch switching internally, so I just added these to avoid leaving the clone in an unpredictable or detached state after the script runs.