optic-rails 0.2.1 → 0.3.0
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.
- checksums.yaml +4 -4
- data/lib/optic/rails.rb +4 -3
- data/lib/optic/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 839393a02e1ac1355010b1f72749cb9ef4c225afb5d448b73b43c01f2fc3031a
|
4
|
+
data.tar.gz: 935ddbf9996bd050150c1e6a2444330710a1dc87d263d4a945f90267ea30ba99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3a55432f89f9aff3dd29272325b81d9992e7e6af1530f61b881b946e8c67375dc6c6eb02dabcde5ec972a02a7ebceee7fd79c4e984f93200a7d232788445af4
|
7
|
+
data.tar.gz: 184cb515429f62a679310b459b9f43d80febc16bdbf1abb5cf05c696a7a5ba472eb85bb181afbe56240c4eef8c89db854d90a60434e2fe9a20c86f2424fdebf3
|
data/lib/optic/rails.rb
CHANGED
@@ -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
|
-
|
154
|
-
reflections.
|
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(
|
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
|
data/lib/optic/rails/version.rb
CHANGED
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.
|
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.
|
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.
|
54
|
+
version: '5.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rgl
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|