From 1475050c898b9acff164da3b5fd440b4af538779 Mon Sep 17 00:00:00 2001 From: JimmyJoo Date: Fri, 24 Jul 2020 04:55:08 +0900 Subject: [PATCH 1/2] Update github-contribution.10m.rb Adjust contribution update time from UTC to local time --- Dev/GitHub/github-contribution.10m.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Dev/GitHub/github-contribution.10m.rb b/Dev/GitHub/github-contribution.10m.rb index ced1ccb50..6bcb6c677 100755 --- a/Dev/GitHub/github-contribution.10m.rb +++ b/Dev/GitHub/github-contribution.10m.rb @@ -80,13 +80,16 @@ module GitHubContribution class Contribution < Struct.new(:username, :contributed_on, :count) RE_CONTRIBUTION = %r|| - def self.find_all_by(username:) [].tap do |contributions| - html = URI.send(:open, url_for(username: username)) { |f| f.read } - + today = Date.parse(DateTime.now.to_s).to_s + year = today.split("-")[0]; + html = URI.send(:open, "https://github.com/users/#{username}/contributions?to=#{today}#year-link-#{year}") { |f| f.read }; + html.scan(RE_CONTRIBUTION) do |count, date| + contributions << Contribution.new(username, Date.parse(date), count.to_i) + end end end @@ -134,7 +137,7 @@ def contribution_text_for(contribution) def contribution_activity_for(contribution) query = "from=#{contribution.contributed_on}" fragment = "year-link-#{contribution.contributed_on.year}" - + "https://github.com/#{contribution.username}?#{query}##{fragment}" end end From 22cbf93e863bf9e2a3fb77d062072c5a989537e8 Mon Sep 17 00:00:00 2001 From: JimmyJoo Date: Fri, 24 Jul 2020 17:54:18 +0900 Subject: [PATCH 2/2] Update github-contribution.10m.rb Make github contribution update to user's local time zone. --- Dev/GitHub/github-contribution.10m.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Dev/GitHub/github-contribution.10m.rb b/Dev/GitHub/github-contribution.10m.rb index 6bcb6c677..8b13fb161 100755 --- a/Dev/GitHub/github-contribution.10m.rb +++ b/Dev/GitHub/github-contribution.10m.rb @@ -85,11 +85,8 @@ def self.find_all_by(username:) today = Date.parse(DateTime.now.to_s).to_s year = today.split("-")[0]; html = URI.send(:open, "https://github.com/users/#{username}/contributions?to=#{today}#year-link-#{year}") { |f| f.read }; - html.scan(RE_CONTRIBUTION) do |count, date| - contributions << Contribution.new(username, Date.parse(date), count.to_i) - end end end @@ -106,10 +103,6 @@ def icon else ':deciduous_tree:' end end - - def self.url_for(username:) - "https://github.com/users/#{username}/contributions" - end end class View @@ -135,7 +128,7 @@ def contribution_text_for(contribution) end def contribution_activity_for(contribution) - query = "from=#{contribution.contributed_on}" + query = "to=#{contribution.contributed_on}" fragment = "year-link-#{contribution.contributed_on.year}" "https://github.com/#{contribution.username}?#{query}##{fragment}"