optic-rails 0.5.1 → 0.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deb632c347be06a488a7fea811d3537138570cd15637d8ed1c131f96ad0ee426
4
- data.tar.gz: e734c0264df8f8bd2acb5c0960f119fdcefb553f5b66b45a7c09498d220a95a8
3
+ metadata.gz: 97fdc801bf28a576a592e12560541b7803d2ca3d2d58594c8e0756662ff0ce46
4
+ data.tar.gz: 30a93912914bb03672659bd451a5f7961ee535e11f2262217dd6a4855c55015c
5
5
  SHA512:
6
- metadata.gz: bf0b7c56b1c435c801ea30ddcc2173ad495557e0beec5ceef63ee86cdf48c6b83deabf2469d54f37ff76f292734181e43359b32954d2486a1e1004422bb3491b
7
- data.tar.gz: aefa1906c06c4ff736c662953c0d046f33d0b3f0b96c832f36374315bcaeb2575d4a685def7b25e385aaacdcb772fbaca1587207c23733ad75135102c1baad21
6
+ metadata.gz: 7c7dbd059fae6f6cbcffcea30116e29da453d86284f220f30551bb3cc49d65721799f097e835259259b5aa3afe284311441a5d55d057da666fb6d3a8e23287e1
7
+ data.tar.gz: 7715d60ca1acaf47d1c8c5b81ddc3cdda7d259e43855f01ef0897a0f0298c3330331e9a16fff9515d1d14db7a276fc36cec75b590072924bbaf7481eccc2e32d
data/lib/optic/rails.rb CHANGED
@@ -57,13 +57,12 @@ module Optic
57
57
  graph = RGL::DirectedAdjacencyGraph.new
58
58
 
59
59
  base_klass = ApplicationRecord rescue ActiveRecord::Base
60
- klasses = ObjectSpace.each_object(Class).find_all { |klass| klass < base_klass }
60
+ klasses = ObjectSpace.each_object(Class).find_all { |klass| klass < base_klass }.find_all(&:table_exists?)
61
61
 
62
62
  graph.add_vertices *klasses
63
63
 
64
64
  klasses.each do |klass|
65
65
  klass.reflect_on_all_associations(:belongs_to).each do |reflection|
66
- # p klass, reflection
67
66
  next if reflection.options[:polymorphic] # TODO
68
67
 
69
68
  # TODO should the source be reflection.active_record or klass?
@@ -77,29 +76,12 @@ module Optic
77
76
  def self.get_entities
78
77
  graph = entity_graph
79
78
 
80
- # Run PageRank on the graph to order the vertices by interestingness
81
- alpha = 0.5 # arbitrary! seems to work!
82
- vertices = graph.vertices
83
-
84
- adjacency_matrix = Array.new(vertices.size) do |i|
85
- Array.new(vertices.size) do |j|
86
- 0
87
- end
88
- end
89
-
90
- graph.edges.each do |edge|
91
- adjacency_matrix[vertices.index(edge.source)][vertices.index(edge.target)] = 1
92
- end
93
-
94
- # TODO run this calculation on the server instead, and pass the full graph (not just the node list)
95
- page_rank = PageRank.new(adjacency_matrix)
96
- init = Array.new(vertices.size, 1.0 / vertices.size.to_f)
97
- ranks = page_rank.calc(init, alpha)
98
- ranked_entities = vertices.zip(ranks).map { |v, r| { name: v.name, table_name: v.table_name, page_rank: r } }.sort_by { |record| record[:page_rank] }.reverse
79
+ # TODO send entire graph to server
80
+ entities = graph.vertices.map { |v| { name: v.name, table_name: v.table_name } }
99
81
 
100
82
  {
101
83
  schema_version: ActiveRecord::Migrator.current_version,
102
- entities: ranked_entities # TODO also return entity attributes?
84
+ entities: entities # TODO also return entity attributes?
103
85
  }
104
86
  end
105
87
 
@@ -1,5 +1,5 @@
1
1
  module Optic
2
2
  module Rails
3
- VERSION = '0.5.1'
3
+ VERSION = '0.5.2'
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.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Vaynshtok