Commit f11e855bdb7f4026a4ec4c553ce7308b9bf71a0a
1 parent
aa36f07a
Exists in
master
and in
4 other branches
Finding free space from the way near commit which is downward
Showing
1 changed file
with
6 additions
and
6 deletions
Show diff stats
app/models/graph/json_builder.rb
| @@ -136,9 +136,9 @@ module Graph | @@ -136,9 +136,9 @@ module Graph | ||
| 136 | end | 136 | end |
| 137 | 137 | ||
| 138 | space = if commit.space >= parent.space then | 138 | space = if commit.space >= parent.space then |
| 139 | - find_free_parent_space(range, parent.space, 1, commit.space, times) | 139 | + find_free_parent_space(range, parent.space, -1, commit.space, times) |
| 140 | else | 140 | else |
| 141 | - find_free_parent_space(range, parent.space, -1, parent.space, times) | 141 | + find_free_parent_space(range, commit.space, -1, parent.space, times) |
| 142 | end | 142 | end |
| 143 | 143 | ||
| 144 | mark_reserved(range, space) | 144 | mark_reserved(range, space) |
| @@ -151,7 +151,7 @@ module Graph | @@ -151,7 +151,7 @@ module Graph | ||
| 151 | 151 | ||
| 152 | def find_free_parent_space(range, space_base, space_step, space_default, times) | 152 | def find_free_parent_space(range, space_base, space_step, space_default, times) |
| 153 | if is_overlap?(range, times, space_default) then | 153 | if is_overlap?(range, times, space_default) then |
| 154 | - find_free_space(range, space_base, space_step) | 154 | + find_free_space(range, space_base, space_step, space_default) |
| 155 | else | 155 | else |
| 156 | space_default | 156 | space_default |
| 157 | end | 157 | end |
| @@ -221,17 +221,17 @@ module Graph | @@ -221,17 +221,17 @@ module Graph | ||
| 221 | end | 221 | end |
| 222 | end | 222 | end |
| 223 | 223 | ||
| 224 | - def find_free_space(time_range, space_base, space_step) | 224 | + def find_free_space(time_range, space_base, space_step, space_default = 1) |
| 225 | reserved = [] | 225 | reserved = [] |
| 226 | for day in time_range | 226 | for day in time_range |
| 227 | reserved += @_reserved[day] | 227 | reserved += @_reserved[day] |
| 228 | end | 228 | end |
| 229 | reserved.uniq! | 229 | reserved.uniq! |
| 230 | 230 | ||
| 231 | - space = space_base | 231 | + space = space_default |
| 232 | while reserved.include?(space) do | 232 | while reserved.include?(space) do |
| 233 | space += space_step | 233 | space += space_step |
| 234 | - if space <= 0 then | 234 | + if space < space_base then |
| 235 | space_step *= -1 | 235 | space_step *= -1 |
| 236 | space = space_base + space_step | 236 | space = space_base + space_step |
| 237 | end | 237 | end |