optic-rails 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb3bf5673fc1c40fb7f1cdc7abef4bd03fd1d000afe33c49d0bb8bebd889bac0
4
- data.tar.gz: cb952112609b5d0f06fb65f292b3b4172eec79af5271b68d574315b899162f20
3
+ metadata.gz: 839393a02e1ac1355010b1f72749cb9ef4c225afb5d448b73b43c01f2fc3031a
4
+ data.tar.gz: 935ddbf9996bd050150c1e6a2444330710a1dc87d263d4a945f90267ea30ba99
5
5
  SHA512:
6
- metadata.gz: a83107da3ea9e779a5874777ad4adf391dffd4f2d3015cf1ce81291d8e4ecfd7aa3fa7aaca0a329821366e5aa15376462b17878ba5c7b2279c7a630a3baab02f
7
- data.tar.gz: b903f2e65c71aabc8949e8e87ab3910020869ef90286c9639facee956963f26c9a182c17488b3cba3bac2af9651adb134b3ba9547d168ce10b3982601d10bf8e
6
+ metadata.gz: a3a55432f89f9aff3dd29272325b81d9992e7e6af1530f61b881b946e8c67375dc6c6eb02dabcde5ec972a02a7ebceee7fd79c4e984f93200a7d232788445af4
7
+ data.tar.gz: 184cb515429f62a679310b459b9f43d80febc16bdbf1abb5cf05c696a7a5ba472eb85bb181afbe56240c4eef8c89db854d90a60434e2fe9a20c86f2424fdebf3
@@ -150,12 +150,13 @@ module Optic
150
150
  belongs_to_names = path.each_cons(2).map do |join_from, join_to|
151
151
  # TODO we shouldn't have to look up the edge again - use a graph model that allows us to annotate the edges with the reflections
152
152
  reflections = join_from.reflect_on_all_associations(:belongs_to).find_all { |reflection| !reflection.options[:polymorphic] && reflection.klass == join_to }
153
- raise "Multiple belongs_to unsupported" unless reflections.size == 1 # TODO
154
- reflections.first.name
153
+ # TODO warn if more than one reflection
154
+ reflection = reflections.min_by { |r| r.options.size }
155
+ reflection.name
155
156
  end
156
157
 
157
158
  joins = belongs_to_names.reverse.inject { |acc, elt| { elt => acc } }
158
- query = vertex.unscoped.joins(joins).group(qualified_primary_key(pivot)).select(qualified_primary_key(pivot), "COUNT(#{qualified_primary_key(vertex)})").to_sql
159
+ query = vertex.unscoped.joins(joins).group(qualified_primary_key(pivot)).select(qualified_primary_key(pivot), "COUNT(*)").to_sql
159
160
 
160
161
  result[:pivoted_totals] << { entity_name: vertex.name, totals: Hash[connection.execute(query).map { |record| [record["id"], record["count"]] }] }
161
162
  else
@@ -1,5 +1,5 @@
1
1
  module Optic
2
2
  module Rails
3
- VERSION = '0.2.1'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optic-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Vaynshtok
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 5.2.0.rc2
47
+ version: '5.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 5.2.0.rc2
54
+ version: '5.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rgl
57
57
  requirement: !ruby/object:Gem::Requirement