-
Couldn't load subscription status.
- Fork 160
Add 'Until' column to contributors index #303
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class AddLastContributionAtToContributors < ActiveRecord::Migration[7.1] | ||
| def up | ||
| add_column :contributors, :last_contribution_at, :datetime | ||
| Contributor.set_last_contribution_timestamps | ||
| end | ||
|
|
||
| def down | ||
| remove_column :contributors, :last_contribution_at | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,34 +4,53 @@ class RepoTest < ActiveSupport::TestCase | |||||
| test '#sync_ranks' do | ||||||
| Repo.new.send(:sync_ranks) | ||||||
|
|
||||||
| {jeremy: 1, david: 2, jose: 3, xavier: 3, vijay: 3}.each do |c, r| | ||||||
| {jeremy: 1, david: 2, jose: 2, xavier: 4, vijay: 4}.each do |c, r| | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a bug. Not introduced here cause it can be observed on the official site. I think it makes more sense that if multiple contributors share a rank the next contributor should be assigned the next rank i.e. this should be:
Suggested change
|
||||||
| assert_equal r, contributors(c).rank | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| test '#sync_first_contributed_timestamps' do | ||||||
| Contributor.update_all(first_contribution_at: nil) | ||||||
| Repo.new.send(:sync_first_contribution_timestamps) | ||||||
| test '#sync_contribution_timestamps' do | ||||||
| Contributor.update_all(first_contribution_at: nil, last_contribution_at: nil) | ||||||
| Repo.new.send(:sync_contribution_timestamps) | ||||||
|
|
||||||
| assert_first_contribution :commit_e0ef631, :david | ||||||
| assert_last_contribution :commit_339e4e8, :david | ||||||
|
|
||||||
| assert_first_contribution :commit_5b90635, :jeremy | ||||||
| assert_last_contribution :commit_b821094, :jeremy | ||||||
|
|
||||||
| assert_first_contribution :commit_5b90635, :jose | ||||||
| assert_last_contribution :commit_e243a8a, :jose | ||||||
|
|
||||||
| assert_first_contribution :commit_26c024e, :xavier | ||||||
| assert_last_contribution :commit_26c024e, :xavier | ||||||
|
|
||||||
| assert_first_contribution :commit_6c65676, :vijay | ||||||
| assert_last_contribution :commit_6c65676, :vijay | ||||||
| end | ||||||
|
|
||||||
| test '#sync_first_contributed_timestamps rebuilding all' do | ||||||
| test '#sync_contribution_timestamps rebuilding all' do | ||||||
| Contributor.update_all( | ||||||
| first_contribution_at: Commit.minimum(:committer_date) - 1.year | ||||||
| first_contribution_at: Commit.minimum(:committer_date) - 1.year, | ||||||
| last_contribution_at: Commit.maximum(:committer_date) + 1.year | ||||||
| ) | ||||||
|
|
||||||
| Repo.new(rebuild_all: true).send(:sync_first_contribution_timestamps) | ||||||
| Repo.new(rebuild_all: true).send(:sync_contribution_timestamps) | ||||||
|
|
||||||
| assert_first_contribution :commit_e0ef631, :david | ||||||
| assert_last_contribution :commit_339e4e8, :david | ||||||
|
|
||||||
| assert_first_contribution :commit_5b90635, :jeremy | ||||||
| assert_last_contribution :commit_b821094, :jeremy | ||||||
|
|
||||||
| assert_first_contribution :commit_5b90635, :jose | ||||||
| assert_last_contribution :commit_e243a8a, :jose | ||||||
|
|
||||||
| assert_first_contribution :commit_26c024e, :xavier | ||||||
| assert_last_contribution :commit_26c024e, :xavier | ||||||
|
|
||||||
| assert_first_contribution :commit_6c65676, :vijay | ||||||
| assert_last_contribution :commit_6c65676, :vijay | ||||||
| end | ||||||
|
|
||||||
| def assert_first_contribution(commit, contributor) | ||||||
|
|
@@ -40,4 +59,11 @@ def assert_first_contribution(commit, contributor) | |||||
|
|
||||||
| assert_equal expected, actual | ||||||
| end | ||||||
|
|
||||||
| def assert_last_contribution(commit, contributor) | ||||||
| expected = commits(commit).committer_date | ||||||
| actual = contributors(contributor).last_contribution_at | ||||||
|
|
||||||
| assert_equal expected, actual | ||||||
| end | ||||||
| end | ||||||
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.
Duplicated below.