mochigome 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mochigome_ver.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mochigome
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/query.rb CHANGED
@@ -30,8 +30,8 @@ module Mochigome
30
30
 
31
31
  @aggregate_rels = {}
32
32
  aggs_by_model.each do |focus_model, data_models|
33
- # Need to do a relation over the entire path in case query runs
34
- # on something other than the focus model layer.
33
+ # Need to do a relation over the entire path in case query has
34
+ # a condition on something other than the focus model layer.
35
35
  # TODO: Would be better to only do this if necesssitated by the
36
36
  # conditions supplied to the query when it is ran, and/or
37
37
  # the access filter.
@@ -42,8 +42,9 @@ module Mochigome
42
42
  f2d_path = self.class.path_thru([focus_model, data_model]) #TODO: Handle nil here
43
43
  agg_path = nil
44
44
  key_path = nil
45
- f2d_path.reverse.each do |link_model|
45
+ f2d_path.each do |link_model|
46
46
  remainder = f2d_path.drop_while{|m| m != link_model}
47
+ next if (remainder.drop(1) & @layers_path).size > 0
47
48
  if @layers_path.include?(link_model)
48
49
  agg_path = remainder
49
50
  key_path = @layers_path.take(@layers_path.index(focus_model)+1)
@@ -52,11 +53,14 @@ module Mochigome
52
53
  # Route it from the closest layer model
53
54
  @layers_path.each_with_index do |layer, i|
54
55
  p = self.class.path_thru([layer, link_model]) + remainder.drop(1)
56
+ next if (p.drop(1) & @layers_path).size > 0
57
+ next if p.uniq.size != p.size
55
58
  if agg_path.nil? || p.size <= agg_path.size
56
59
  agg_path = p
57
60
  key_path = @layers_path.take(i+1)
58
61
  end
59
62
  end
63
+ break if agg_path # Use as much of f2d_path as we can
60
64
  end
61
65
  end
62
66
 
@@ -239,6 +239,9 @@ describe Mochigome::Query do
239
239
  assert_equal 24, data_node['Sales count']
240
240
  end
241
241
 
242
+ # TODO: Include test here against the bug I saw in JSAS where
243
+ # it would avoid including the focus if there was a shorter path.
244
+
242
245
  it "does not collect aggregate data for layers below focus" do
243
246
  q = Mochigome::Query.new(
244
247
  [Owner, Store, Product, Category],
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mochigome
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Mike Simon
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-09 00:00:00 Z
18
+ date: 2012-03-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement