Skip to content
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

complicated nested finds #171

Closed
thoraxe opened this issue Dec 23, 2015 · 0 comments
Closed

complicated nested finds #171

thoraxe opened this issue Dec 23, 2015 · 0 comments

Comments

@thoraxe
Copy link

thoraxe commented Dec 23, 2015

I'm building a report using the Trello gem, which is totally awesome! I am trying to find cards in lists that have particular labels, and am having a bear of a time figuring it out. I have lists that are called "sprint" (like agile) and then some cards in those lists have the "project" label.

Finding the sprints is pretty easy:

pmm_board.lists(:filter => :all).each do |list|
  if list.name.downcase.include? "sprint"
    sprint_lists << list
  end
end

And I will iterate over each list and then try to find its cards... but there doesn't seem to be a way to "find card with label" in any easy way.

So, given the cards in a particular list, eg sprint_lists[0].cards I am trying to do something like:

sprint_lists[1].cards.find { |card| card.card_labels.any? { |label| label["id"] == "54d4de9c74d650d5671cb3c7" } }

In other words, among the sprint_lists[1].cards i want to find any card whose card_labels array contains a label with the id of 54d4de9c74d650d5671cb3c7.

The nested enum-y/find-y thing above works, but only returns the first card in the list with that label.

Is there an easier way to find cards in a list with a particular label?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants