closure_tree 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -331,10 +331,10 @@ Closure tree is [tested under every combination](http://travis-ci.org/#!/mceache
331
331
 
332
332
  ## Change log
333
333
 
334
- ### 3.5.0
334
+ ### 3.5.1
335
335
 
336
336
  * Added ```find_all_by_generation```
337
- for [feature request 17](https://github.com/mceachen/closure_tree/issues/17)).
337
+ for [feature request 17](https://github.com/mceachen/closure_tree/issues/17).
338
338
 
339
339
  ### 3.4.2
340
340
 
@@ -87,23 +87,9 @@ module ClosureTree
87
87
  roots.inject(ActiveSupport::OrderedHash.new) { |h, ea| h.merge(ea.hash_tree(options)) }
88
88
  end
89
89
 
90
- def find_all_by_generation(generation_level)
91
- s = joins(<<-SQL)
92
- INNER JOIN (
93
- SELECT #{primary_key} as root_id
94
- FROM #{quoted_table_name}
95
- WHERE #{quoted_parent_column_name} IS NULL
96
- ) AS roots
97
- INNER JOIN (
98
- SELECT ancestor_id, descendant_id
99
- FROM #{quoted_hierarchy_table_name}
100
- GROUP BY 1, 2
101
- HAVING MAX(#{quoted_hierarchy_table_name}.generations) = #{generation_level.to_i}
102
- ) AS descendants
103
- ON #{quoted_table_name}.#{primary_key} = descendants.descendant_id
104
- AND roots.root_id = ancestor_id
105
- SQL
106
- order_option ? s.order(order_option) : s
90
+ def self.find_all_by_generation(generation_level)
91
+ # TODO: make this be a proper SQL select, not an inject.
92
+ roots.inject([]) { |a, ea| a + ea.find_all_by_generation(generation_level).to_a }
107
93
  end
108
94
 
109
95
  def self.leaves
@@ -1,3 +1,3 @@
1
1
  module ClosureTree
2
- VERSION = "3.5.0" unless defined?(::ClosureTree::VERSION)
2
+ VERSION = "3.5.1" unless defined?(::ClosureTree::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closure_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -192,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  segments:
194
194
  - 0
195
- hash: 1009921537345124595
195
+ hash: 10070411071183028
196
196
  required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  none: false
198
198
  requirements:
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  segments:
203
203
  - 0
204
- hash: 1009921537345124595
204
+ hash: 10070411071183028
205
205
  requirements: []
206
206
  rubyforge_project:
207
207
  rubygems_version: 1.8.23