Class: GithubReactions::QueryExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/github_reactions/query_executor.rb

Class Method Summary collapse

Class Method Details

.get(repository_name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/github_reactions/query_executor.rb', line 10

def get(repository_name)
  reaction_groups = []

  after = nil

  0.step do |i|
    result = GraphQL::Client.query(
      GraphQL::Client::ReactionQuery,
      {
          q: "repo:#{repository_name}",
          after: after,
      })

    puts "Fetched #{GraphQL::Client::BATCH_SIZE * i + result.data.search.nodes.size} / #{result.data.search.issue_count}... #{Visualizer::EMOJI_UNICORD_MAP.values.sample}"

    result.data.search.nodes.each do |node|
      reaction_groups << node.reaction_groups
    end

    if result.data.search.page_info.has_next_page
      after = result.data.search.page_info.end_cursor
    else
      break
    end
  end

  reaction_groups
end