Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Fix a bug of updating Build#incremental_id #6

Merged
merged 1 commit into from
Jul 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def finish(result)
end

def update_incremental_id
update_attributes(incremental_id: job.builds_count)
update_attributes(incremental_id: job.builds.count)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your Pull-Request, but this change slows things down because it loses the benefit of counter cache.
I think what we should do for this problem are:

  1. Set a default value of jobs.build_count with 0 in a migration file
  2. Change incremental_id so that it starts with 1

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this issue after merging your pull-request 👍

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixed this, thx!

end

private
Expand Down
2 changes: 2 additions & 0 deletions spec/models/build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
build.started_at.should be_present
build.finished_at.should be_present
build.status.should == true
build.incremental_id.should_not be_nil
end
end

Expand All @@ -29,6 +30,7 @@
build.started_at.should be_present
build.finished_at.should be_present
build.status.should == false
build.incremental_id.should_not be_nil
end
end
end
Expand Down