Skip to content

Commit

Permalink
Adds basic filter to ensure only open issues get listed
Browse files Browse the repository at this point in the history
  • Loading branch information
bougyman committed Jan 25, 2024
1 parent b94b601 commit 7bbcfbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/linear/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def self.included(mod)

def display(subject, options)
return puts(JSON.neat_generate(subject)) if options[:output] == "json"
return subject.display if subject.respond_to?(:display)
unless subject.respond_to?(:each)
return subject.each(&:display) if subject.respond_to?(:each)
unless subject.respond_to?(:display)
raise SmellsBad, "Cannot display #{subject}, there is no #display method and it is not a collection"
end

subject.each(&:display)
subject.display
end
end

Expand Down
14 changes: 6 additions & 8 deletions lib/linear/models/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Issue
include GQLi::DSL
include SemanticLogger::Loggable

BASIC_FILTER = { completedAt: { null: true } }.freeze

Base = fragment("BaseIssue", "Issue") do
id
identifier
Expand All @@ -23,7 +25,7 @@ class Issue

def self.allq(filter: nil, limit: 50, after: nil) # rubocop:disable Metrics/MethodLength
args = { first: limit }
args[:filter] = filter if filter
args[:filter] = filter ? BASIC_FILTER.merge(filter) : BASIC_FILTER
args[:after] = after if after
query do
issues(args) do
Expand All @@ -40,17 +42,13 @@ def self.issues_query(filter: nil, after: nil)
Api.query(allq(filter:, after:))
end

def self.all(edges: [], moar: true, after: nil, filter: nil) # rubocop:disable Metrics/MethodLength
def self.all(edges: [], moar: true, after: nil, filter: nil, max: 100)
while moar
data = issues_query(filter:, after:)
issues = data[:issues]
edges += issues[:edges]
if issues[:pageInfo][:hasNextPage]
after = issues[:pageInfo][:endCursor]
else
moar = false
end
require 'pry'; binding.pry
moar = false if edges.size >= max || !issues[:pageInfo][:hasNextPage]
after = issues[:pageInfo][:endCursor]
end
edges.map { |edge| new edge[:node] }
end
Expand Down

0 comments on commit 7bbcfbd

Please sign in to comment.