Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ KalibroProcessor is the processing web service for Mezuro.

== Unreleased

* Improve ModuleResults tree pre_order retrieval performance
* Fix possible inconsistency in module result creation (lack of transaction)
* Improve acceptance tests by fixing small bugs and adding processing times
* Introduce performance tests for Aggregator
Expand Down
7 changes: 4 additions & 3 deletions app/models/module_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ def to_json(options={})
end

def pre_order
root = self
root = root.parent until root.parent.nil?
@pre_order ||= pre_order_traverse(root).to_a
return @pre_order unless @pre_order.nil?
return processing.root_module_result.pre_order unless parent.nil?

@pre_order = pre_order_traverse(self).to_a
end

def descendants
Expand Down
6 changes: 5 additions & 1 deletion spec/models/module_result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,15 @@
context 'when it is not the root module result' do
let!(:root) { FactoryGirl.build(:module_result, id: 1)}
let!(:child) { FactoryGirl.build(:module_result, id: 2)}
let!(:processing) { FactoryGirl.build(:processing, root_module_result: root)}

before :each do
child.expects(:parent).twice.returns(root)
child.expects(:parent).returns(root)
child.expects(:processing).returns(processing)
root.expects(:parent).returns(nil)
root.expects(:children).returns([child])
end

it 'is expected to return the complete pre order tree traversal (from root)' do
expect(child.pre_order).to eq([root, child])
end
Expand Down