-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let instance view return instance DTSTART and DUE rather than the tas… #620
Conversation
…k values. Implements #615 This commit improves the instances view by returning the instance start and due times as task `DTSTART` and `DUE`. This way the UI will see the correct instance times. From the UI perspective the instances view is now a list of individual non-recurring instances, which can be read and written on its own. Note, for non-recurring tasks, this won't have any effect.
* Note: The {@link #DTSTART}, {@link #DUE} values of instances of recurring tasks represent the actual instance values, i.e. they are different for each | ||
* instance ({@link #DURATION} is always {@code null}). | ||
* <p> | ||
* Also, none of the instances are recurring themselves, so {@link #RRULE}, {@link #RDATE} and {@link #EXDATE} are always {@code null}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to consider not using all of the TaskColumns
in Instances
here?
Since DURATION
, RRULE
, RDATE
, EXDATE
are always null
.
Having something like a CommonTaskColumns
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, the instances table should be compatible with the tasks table, i.e. instances are special case of a task. In particular, a projection that works on the task table should work on the instances table as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
+ Tables.LISTS + "." + Tasks.LIST_COLOR + ", " | ||
+ Tables.LISTS + "." + Tasks.VISIBLE | ||
+ " FROM " + Tables.TASKS | ||
+ " JOIN " + Tables.LISTS + " ON (" + Tables.TASKS + "." + TaskContract.Tasks.LIST_ID + "=" + Tables.LISTS + "." + TaskContract.Tasks._ID + ")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the end of the first join, shouldn't TaskContract.Tasks._ID
be TaskContract.TaskLists._ID
instead? I know it's effectively the same, but just for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I'll fix that.
@@ -79,7 +80,14 @@ public InstanceTestData(@NonNull Optional<DateTime> instanceStart, @NonNull Opti | |||
.withValue(TaskContract.Instances.INSTANCE_DURATION, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the Instances.INSTANCE_DURATION
column need at all if it is always DUE
which is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instances.INSTANCE_DURATION
was added for two reasons:
- provide an easy way to the UI to get the actual absolute duration of an instance
- provide an easy way to filter instances by their duration (e.g. in an SQL query)
both could certainly achieved with Instances.INSTANCE_START
and Instances.INSTANCE_DUE
, but considering that these might also be null
(which would be returned as 0
by Cursor.getLong(int)
), it would require more work work to achieve that without a duration column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I realized that I mistook the override in the VIEW, I though it was INSTANCE_DURATION that is nulled but that's Tasks.DURATION... Ok, I see it then why this is needed.
@lemonboston I've fixed the _ID column and also mapped the ORIGINAL_INSTANCE_TIME value to the actual instance value. This is a bit more complicated because the instances table contains |
And what is the reason for Instances table using |
// override task due and start times with the instance values | ||
+ Tables.INSTANCES + "." + TaskContract.Instances.INSTANCE_START + " as " + Tasks.DTSTART + ", " | ||
+ Tables.INSTANCES + "." + TaskContract.Instances.INSTANCE_DUE + " as " + Tasks.DUE + ", " | ||
// also replace ORIGINAL_INSTANCE_TIME. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it needed to replace ORIGINAL_INSTANCE_TIME? Doesn't it break the specification for that column on the contract? Its value will be different from what the docs says there, if I am not mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No not really. ORIGINAL_INSTANCE_TIME
is the time at which an instance occurs as per the specification in the master. The instances view represents a flattened view on the tasks, where each task instance is represented as a non-recurring override. Or in other words, it "emulates" an override for each instance of every (recurring or non-recurring) task.
So to me it makes sense to also "emulate" ORIGINAL_INSTANCE_TIME
if present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still a bit confusing for me. Could you please remind me why is the Instances.INSTANCE_ORIGINAL_TIME
column needed?
The docs for the two columns talk about almost the same things but with a bit different wording. Could it be maybe updated to be phrased the same? It could be easier to see the difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using Instances.INSTANCE_ORIGINAL_TIME
primarily as a sorting key for all instanced of a recurring task. Without it I can't sort regular instances and overrides in the correct order. Correct sorting is very helpful when syncing the instances specified in the master with the instances in the database.
Also, with this column it is easier to handle recurring tasks without a start. In this case we assume start == due
and store that as the INSTANCE_ORIGINAL_TIME
. Without it, we would have to check at usage time which value we need to use, start or due (because we still store null
in the start column).
The instances table uses |
Hmm... there seems to be only one place where it actually matters, I guess I can drop this requirement. |
@lemonboston I dropped the requirement of using |
Simplyfy instance view `ORIGINAL_INSTANCE_TIME`
c058759
to
768a7b5
Compare
@lemonboston I've also added some JavaDoc to the Instances contract to explain how the operations will affect the tasks. The insert behavior is not fully implemented yet, at least not in this branch. I'll post a separate PR to fix this. |
Those javadocs for the Instances table look very useful. I've checked the changes, no more questions from me besides the one about the ORIGINAL_TIMEs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussing the purpose of ORIGINAL_INSTANCE_TIME column on Slack, it is now clearer for me.
Regarding looking at every row in Instances table as overrides, would it make sense to add this note, too, to the Instances contact javadoc? Perhaps mentioning INSTANCE_ORIGINAL_TIME explicitly?
…k values. Implements #615
This commit improves the instances view by returning the instance start and due times as task
DTSTART
andDUE
. This way the UI will see the correct instance times.From the UI perspective the instances view is now a list of individual non-recurring instances, which can be read and written on its own.
Note, for non-recurring tasks, this won't have any effect.