-
Notifications
You must be signed in to change notification settings - Fork 204
Split Tasks
With Shotgun 4.2 a concept of split tasks was introduced. These split tasks can be created and edited via the API but must comply to some rules.
Before going further a good understanding of how Shotgun handles task dates is useful.
The Task entity now has a new field called splits
which is a list of dictionaries. Each dictionary in the list has two string keys, start
and end
, who's values are strings representing dates in the YYYY-mm-dd
format.
[{'start': '2012-12-11', 'end': '2012-12-12'}, {'start': '2012-12-18', 'end': '2012-12-19'}]
- Splits should be ordered from eldest to newest.
- There should be gaps between each split.
- Gaps are defined as at least one working day. Non-workdays such as weekends and holidays are not gaps.
Alternately, a split value can be set to None
to remove splits (you can also use an empty list). This will preserve the start_date
and due_date
values but recalculate the duration
value while appropriately considering all workday rules in effect.
- If splits are specified the supplied
start_date
,due_date
andduration
fields will be ignored. - The
start_date
will be inferred from the earliest split. - The
due_date
will be inferred from the last split. - If the
start_date
is changed on a task that has splits the first split will be moved to start on the newstart_date
and all further splits will be moved while maintaining gap lengths between splits and respecting workday rules. - If the
due_date
is changed on a task that has splits the last split will be moved to end on the newdue_date
and all prior splits will be moved while maintaining gap lengths between splits and respecting workday rules. - If the
duration
is changed two scenarios are possible- In the case of a longer duration, additional days will be added to the end of the last split
- In the case of a shorter duration splits, starting with the latest ones, will be either removed or shortened until the new duration is met.
Throughout the following examples, each successive one will build on the previous.
sg.update('Task', 2088, {
'start_date': '2012-12-06',
'due_date': '2012-12-23',
'duration': 3600,
'splits': [
{'start': '2012-12-11', 'end': '2012-12-12'},
{'start': '2012-12-18', 'end': '2012-12-19'}
]
})
# Task = {
# 'start_date': '2012-12-11',
# 'due_date': '2012-12-19',
# 'duration': 2400,
# 'splits': [
# {'start': '2012-12-11', 'end': '2012-12-12'},
# {'start': '2012-12-18', 'end': '2012-12-19'}
# ]
# }
Result:
sg.update('Task', 2088, {
'start_date': '2012-12-10'
})
# Task = {
# 'start_date': '2012-12-10',
# 'due_date': '2012-12-18',
# 'splits': [
# {'start': '2012-12-10', 'end': '2012-12-11'},
# {'start': '2012-12-14', 'end': '2012-12-18'}
# ]
# }
Result:
sg.update('Task', 2088, {
'due_date': '2012-12-19'
})
# Task = {
# 'start_date': '2012-12-10',
# 'due_date': '2012-12-19',
# 'splits': [
# {'start': '2012-12-10', 'end': '2012-12-11'},
# {'start': '2012-12-14', 'end': '2012-12-19'}
# ]
# }
Result:
sg.update('Task', 2088, {
'duration': 4200
})
# Task = {
# 'start_date': '2012-12-10',
# 'due_date': '2012-12-21',
# 'duration': 4200,
# 'splits': [
# {'start': '2012-12-10', 'end': '2012-12-11'},
# {'start': '2012-12-14', 'end': '2012-12-21'}
# ]
# }
Result:
sg.update('Task', 2088, {
'duration': 2400
})
# Task = {
# 'start_date': '2012-12-10',
# 'due_date': '2012-12-18',
# 'duration': 2400,
# 'splits': [
# {'start': '2012-12-10', 'end': '2012-12-11'},
# {'start': '2012-12-14', 'end': '2012-12-18'}
# ]
# }
Result:
We won't be using the previous result for this example but rather, the following:
who's duration
we will shorten past the last split.
sg.update('Task', 2088, {
'duration': 1800
})
# Task = {
# 'start_date': '2012-12-10',
# 'due_date': '2012-12-18',
# 'duration': 2400,
# 'splits': [
# {'start': '2012-12-10', 'end': '2012-12-11'},
# {'start': '2012-12-14', 'end': '2012-12-18'}
# ]
# }
Result:
When a due date is set in a gap later splits are removed and the day of the due date is considered a day when work will be done
For this example let's assume as a starting point the result of the 5th example.
sg.update('Task', 2088, {
'due_date': '2012-12-13'
})
# Task = {
# 'start_date': '2012-12-10',
# 'due_date': '2012-12-13',
# 'duration': 1800,
# 'splits': [
# {'start': '2012-12-10', 'end': '2012-12-11'},
# {'start': '2012-12-13', 'end': '2012-12-13'}
# ]
# }
Result: