Skip to content

Commit

Permalink
[59539] Update seeding data to be compatible with new automatic sched…
Browse files Browse the repository at this point in the history
…uling mode
  • Loading branch information
cbliard committed Dec 17, 2024
1 parent 28f0719 commit 7923850
Show file tree
Hide file tree
Showing 13 changed files with 427 additions and 153 deletions.
17 changes: 15 additions & 2 deletions app/models/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,23 @@ def label_for(work_package)
TYPES[relation_type] ? TYPES[relation_type][key] : :unknown
end

def predecessor = to
def predecessor_id = to_id
def successor = from
def successor_id = from_id

def predecessor_date
predecessor.due_date || predecessor.start_date
end

def successor_date
successor.start_date || successor.due_date
end

def successor_soonest_start
if follows? && (to.start_date || to.due_date)
if follows? && predecessor_date
days = WorkPackages::Shared::Days.for(from)
relation_start_date = (to.due_date || to.start_date) + 1.day
relation_start_date = predecessor_date + 1.day
days.soonest_working_day(relation_start_date, lag:)
end
end
Expand Down
11 changes: 10 additions & 1 deletion app/seeders/demo_data/work_package_seeder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def work_package_attributes
due_date:,
duration:,
ignore_non_working_days:,
schedule_manually:,
estimated_hours:
}
end
Expand All @@ -213,7 +214,7 @@ def initialize(attributes)

def start_date
days_ahead = attributes["start"] || 0
Time.zone.today.monday + days_ahead.days
Date.current.monday + days_ahead.days
end

def due_date
Expand All @@ -230,6 +231,14 @@ def ignore_non_working_days
.any? { |date| working_days.non_working?(date) }
end

def schedule_manually
if attributes["schedule_manually"].nil?
WorkPackage.column_defaults["schedule_manually"]
else
ActiveModel::Type::Boolean.new.cast(attributes["schedule_manually"])
end
end

def estimated_hours
attributes["estimated_hours"]&.to_i
end
Expand Down
161 changes: 83 additions & 78 deletions app/seeders/standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ projects:
options:
t_name: 'Milestones'
queryId: '##query.id:demo_project__query__milestones'
# For all dates, the reference is the monday of the current week
# For all dates, the reference is the Monday of the current week
# So
# * start: 0 references Monday
# * start: 4 references Friday
Expand All @@ -255,20 +255,24 @@ projects:
status: :default_status_closed
type: :default_type_milestone
duration: 1
schedule_manually: false
schedule_manually: true
- start: 0
t_subject: Organize open source conference
reference: :organize_open_source_conference
description: ''
status: :default_status_in_progress
type: :default_type_phase
duration: 15
schedule_manually: false
children:
- start: 0
t_subject: Set date and location of conference
reference: :set_date_and_location_of_conference
description: ''
status: :default_status_in_progress
type: :default_type_task
duration: 4
schedule_manually: false
children:
- start: 0
t_subject: Send invitation to speakers
Expand All @@ -288,32 +292,28 @@ projects:
status: :default_status_new
type: :default_type_task
duration: 4
duration: 4
schedule_manually: false
- start: 4
t_subject: Invite attendees to conference
reference: :invite_attendees_to_conference
description: ''
status: :default_status_new
type: :default_type_task
duration: 1
schedule_manually: false
relations:
- to: :set_date_and_location_of_conference
type: follows
schedule_manually: false
- start: 4
t_subject: Setup conference website
reference: :setup_conference_website
description: ''
status: :default_status_new
type: :default_type_task
duration: 11
schedule_manually: false
relations:
- to: :set_date_and_location_of_conference
type: follows
schedule_manually: false
duration: 15
schedule_manually: true
- start: 15
t_subject: Conference
description: ''
Expand All @@ -330,6 +330,8 @@ projects:
description: ''
status: :default_status_to_be_scheduled
type: :default_type_phase
duration: 11
schedule_manually: false
children:
- start: 21
t_subject: Upload presentations to website
Expand All @@ -338,7 +340,6 @@ projects:
status: :default_status_new
type: :default_type_task
duration: 10
schedule_manually: false
- start: 31
t_subject: Party for conference supporters :-)
t_description: |-
Expand All @@ -349,19 +350,16 @@ projects:
status: :default_status_new
type: :default_type_task
duration: 1
schedule_manually: false
duration: 11
schedule_manually: false
- start: 32
t_subject: End of project
description:
status: :default_status_new
type: :default_type_milestone
duration: 1
schedule_manually: false
relations:
- to: :follow_up_tasks
type: follows
schedule_manually: false
t_wiki: |
_In this wiki you can collaboratively create and edit pages and sub-pages to create a project wiki._
Expand Down Expand Up @@ -619,6 +617,7 @@ projects:
type: :default_type_epic
start: 0
duration: 29
schedule_manually: false
children:
- t_subject: Newsletter registration form
status: :default_status_in_progress
Expand All @@ -638,6 +637,7 @@ projects:
story_points: 3
start: 28
duration: 1
schedule_manually: false
children:
- t_subject: Create wireframes for new landing page
status: :default_status_in_progress
Expand All @@ -659,6 +659,7 @@ projects:
version: :scrum_project__version__sprint_1
position: 3
story_points: 5
schedule_manually: false
children:
- t_subject: Make screenshots for feature tour
status: :default_status_closed
Expand Down Expand Up @@ -705,6 +706,7 @@ projects:
story_points: 3
start: 25
duration: 1
schedule_manually: false
children:
- t_subject: Set up navigation concept for website.
status: :default_status_in_specification
Expand All @@ -724,12 +726,13 @@ projects:
status: :default_status_in_progress
type: :default_type_phase
start: 14
duration: 3
duration: 4
- t_subject: Release v1.0
status: :default_status_new
type: :default_type_milestone
start: 18
duration: 1
schedule_manually: false
relations:
- to: :develop_v1_0
type: follows
Expand All @@ -738,12 +741,13 @@ projects:
status: :default_status_new
type: :default_type_phase
start: 21
duration: 3
duration: 4
- t_subject: Release v1.1
status: :default_status_new
type: :default_type_milestone
start: 25
duration: 1
schedule_manually: false
relations:
- to: :develop_v1_1
type: follows
Expand All @@ -752,12 +756,13 @@ projects:
status: :default_status_new
type: :default_type_phase
start: 28
duration: 3
duration: 4
- t_subject: Release v2.0
status: :default_status_new
type: :default_type_milestone
start: 32
duration: 1
schedule_manually: false
relations:
- to: :develop_v2_0
type: follows
Expand Down Expand Up @@ -940,80 +945,80 @@ types:
workflows:
- type: :default_type_task
statuses:
- :default_status_new
- :default_status_in_progress
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- :default_status_new
- :default_status_in_progress
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- type: :default_type_milestone
statuses:
- :default_status_new
- :default_status_to_be_scheduled
- :default_status_scheduled
- :default_status_in_progress
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- :default_status_new
- :default_status_to_be_scheduled
- :default_status_scheduled
- :default_status_in_progress
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- type: :default_type_phase
statuses:
- :default_status_new
- :default_status_to_be_scheduled
- :default_status_scheduled
- :default_status_in_progress
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- :default_status_new
- :default_status_to_be_scheduled
- :default_status_scheduled
- :default_status_in_progress
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- type: :default_type_feature
statuses:
- :default_status_new
- :default_status_in_specification
- :default_status_specified
- :default_status_in_progress
- :default_status_developed
- :default_status_in_testing
- :default_status_tested
- :default_status_test_failed
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- :default_status_new
- :default_status_in_specification
- :default_status_specified
- :default_status_in_progress
- :default_status_developed
- :default_status_in_testing
- :default_status_tested
- :default_status_test_failed
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- type: :default_type_epic
statuses:
- :default_status_new
- :default_status_in_specification
- :default_status_specified
- :default_status_in_progress
- :default_status_developed
- :default_status_in_testing
- :default_status_tested
- :default_status_test_failed
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- :default_status_new
- :default_status_in_specification
- :default_status_specified
- :default_status_in_progress
- :default_status_developed
- :default_status_in_testing
- :default_status_tested
- :default_status_test_failed
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- type: :default_type_user_story
statuses:
- :default_status_new
- :default_status_in_specification
- :default_status_specified
- :default_status_in_progress
- :default_status_developed
- :default_status_in_testing
- :default_status_tested
- :default_status_test_failed
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- :default_status_new
- :default_status_in_specification
- :default_status_specified
- :default_status_in_progress
- :default_status_developed
- :default_status_in_testing
- :default_status_tested
- :default_status_test_failed
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- type: :default_type_bug
statuses:
- :default_status_new
- :default_status_confirmed
- :default_status_in_progress
- :default_status_developed
- :default_status_in_testing
- :default_status_tested
- :default_status_test_failed
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed
- :default_status_new
- :default_status_confirmed
- :default_status_in_progress
- :default_status_developed
- :default_status_in_testing
- :default_status_tested
- :default_status_test_failed
- :default_status_on_hold
- :default_status_rejected
- :default_status_closed

welcome:
t_title: "Welcome to OpenProject!"
Expand Down
7 changes: 7 additions & 0 deletions app/services/work_packages/shared/all_days.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def duration(start_date, due_date)
(start_date..due_date).count
end

# Returns the number of working days between a predecessor date and
# successor date, exclusive.
def lag(predecessor_date, successor_date)
# lag is *always* excluding non-working days (at least for now)
WorkingDays.new.lag(predecessor_date, successor_date)
end

def start_date(due_date, duration)
return nil unless due_date && duration
raise ArgumentError, "duration must be strictly positive" if duration.is_a?(Integer) && duration <= 0
Expand Down
Loading

0 comments on commit 7923850

Please sign in to comment.