Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/fbe/github_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def pull_requests_with_reviews(owner, name, since, cursor: nil)
id
number
updatedAt
timelineItems(first: 1, itemTypes: [PULL_REQUEST_REVIEW], since: "#{since.utc.iso8601}") {
timelineItems(first: 1, itemTypes: [PULL_REQUEST_REVIEW], since: "#{since.getutc.iso8601}") {
nodes {
... on PullRequestReview { id }
}
Expand Down Expand Up @@ -463,7 +463,7 @@ def total_commits_pushed(owner, name, since, till = Time.now)
defaultBranchRef {
target {
... on Commit {
history(#{after}first: 100, since: "#{since.utc.iso8601}", until: "#{till.utc.iso8601}") {
history(#{after}first: 100, since: "#{since.getutc.iso8601}", until: "#{till.getutc.iso8601}") {
totalCount
nodes {
oid
Expand Down Expand Up @@ -507,7 +507,7 @@ def total_commits_pushed(owner, name, since, till = Time.now)
# @param [Time] till The datetime to
# @return [Hash] A hash with total issues and pulls
def total_issues_created(owner, name, since, till = Time.now)
window = "created:#{since.utc.iso8601}..#{till.utc.iso8601}"
window = "created:#{since.getutc.iso8601}..#{till.getutc.iso8601}"
result = query(
<<~GRAPHQL
{
Expand Down
46 changes: 46 additions & 0 deletions test/fbe/test_github_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1058,4 +1058,50 @@ def test_fake_total_releases_published_dont_count_after_till
h = graph.total_releases_published(owner, name, since, till: since + 60)
assert_equal(1, h['releases'], "the fake counts releases published after the till moment, seed: #{seed}")
end

def test_total_issues_created_keeps_the_given_since
seed = Random.new_seed
t = Time.new(2025, 1, 1, 10, 0, 0, format('+%02d:00', Random.new(seed).rand(1..12)))
g = Fbe::Graph.new(token: 'fake')
g.stub(:query, ->(_q) { {} }) { g.total_issues_created('o', 'n', t, t + 3600) }
refute_predicate(t, :utc?, "since is converted to UTC in place, seed #{seed}")
end

def test_total_issues_created_accepts_frozen_since
t = Time.new(2025, 1, 1, 10, 0, 0, '+03:00').freeze
g = Fbe::Graph.new(token: 'fake')
h = g.stub(:query, ->(_q) { {} }) { g.total_issues_created('o', 'n', t, t + 3600) }
assert_equal(0, h['issues'], 'frozen since is refused')
end

def test_total_issues_created_renders_the_window_in_utc
t = Time.new(2025, 1, 1, 10, 0, 0, '+03:00')
g = Fbe::Graph.new(token: 'fake')
seen = nil
g.stub(:query, ->(q) { seen = q and {} }) { g.total_issues_created('o', 'n', t, t + 3600) }
assert_includes(seen, 'created:2025-01-01T07:00:00Z..2025-01-01T08:00:00Z', 'window is not rendered in UTC')
end

def test_total_commits_pushed_keeps_the_given_till
seed = Random.new_seed
t = Time.new(2025, 1, 1, 10, 0, 0, format('-%02d:00', Random.new(seed).rand(1..11)))
g = Fbe::Graph.new(token: 'fake')
g.stub(:query, ->(_q) { { 'repository' => {} } }) { g.total_commits_pushed('o', 'n', t - 3600, t) }
refute_predicate(t, :utc?, "till is converted to UTC in place, seed #{seed}")
end

def test_total_commits_pushed_accepts_frozen_since
t = Time.new(2025, 1, 1, 10, 0, 0, '+03:00').freeze
g = Fbe::Graph.new(token: 'fake')
h = g.stub(:query, ->(_q) { { 'repository' => {} } }) { g.total_commits_pushed('o', 'n', t, t + 3600) }
assert_equal(0, h['commits'], 'frozen since is refused')
end

def test_pull_requests_with_reviews_accepts_frozen_since
t = Time.new(2025, 1, 1, 10, 0, 0, '+03:00').freeze
g = Fbe::Graph.new(token: 'fake')
answer = { 'repository' => { 'pullRequests' => { 'nodes' => [], 'pageInfo' => { 'hasNextPage' => false } } } }
h = g.stub(:query, ->(_q) { answer }) { g.pull_requests_with_reviews('o', 'n', t) }
assert_empty(h['pulls_with_reviews'], 'frozen since is refused')
end
end
Loading