-
Notifications
You must be signed in to change notification settings - Fork 17
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
Patch to show for #79: show "yellow" To-Dos in Today and remove them from Upcoming #80
Conversation
Codecov Report
@@ Coverage Diff @@
## main #80 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 341 352 +11
=========================================
+ Hits 341 352 +11
Continue to review full report at Codecov.
|
@mikez will test tomorrow when having yellow tasks - feel free to already comment on the changes. |
I took a look!
|
Another idea for (1.): add the string options Also, a technical remark: I've noticed that |
Some suggestions:
|
No special reason, changed it now. Also created #81 because of this, as currently we have for example
I gave it a shot.
Done, however, see #81 - I'm thinking more about exploiting types (enums, classes, ...) or type hints here sooner or later.
Done. |
The convention I used here was to always do lower case except for where the Things App has a different convention. "Inbox", "Anytime", etc. are special nouns involving GTD collection names; they're title-cased in the app. It is fine to use start="inbox" though, since we run the line |
I will take a look at your changes and comment as soon as possible. |
…ion date) tasks with a due date, calculated some test expectations, reordered some expectations
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.
Thanks for your patience, @AlexanderWillner. Commented. I hope it's helpful.
return { | ||
None: "", | ||
False: f"AND {column} IS NULL", | ||
True: f"AND {column} IS NOT NULL", | ||
}.get(value, default) | ||
|
||
|
||
def make_date_filter(date_column, offset): | ||
def make_date_filter(date_column: str, offset) -> str: |
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 think this function is getting too complex. I find it hard to read.
Maybe split it out into two functions?
make_date_range_filter
("3d"
,"2w"
,"5y"
)make_date_filter
(True
,False
,"future"
,"past"
)
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.
Personal gut feeling: keep it. These functions would be very similar in what they want to achieve and the current version is around 20 lines of code. But also fine splitting it.
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 vote for splitting. It seems hard to read, especially for somebody who's never seen this code before.
A date range filter (specified by an offset) and a date filter (True, False, "past", "future) seems more readable for me.
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.
One can always merge again if it seems too redundant. I much prefer many smaller functions.
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.
Created #82 for this
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 break it out into a separate PR?
The proposal was to rename make_date_filter
to make_date_range_filter
, but leave it as-is. Then, to add a new function called make_date_filter
which operates on True, False, None, "future", "past"
.
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.
Mh:
- In case of None: return ""
- In case of True/False: return make_filter
- In case of Future/Past: set offset to 0 and specify operator
The new method would duplicate the actual code
column_datetime = f"datetime({date_column}, 'unixepoch', 'localtime')"
offset_datetime = f"datetime('now', 'localtime', '{modifier}')" # type: ignore
Wouldn't it?
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.
For the case of "future" and "past", my thinking was to call make_date_range_filter
from within make_date_filter
. Or.. what do you think?
@AlexanderWillner I think we're almost there with this review. I look forward when we can merge this in. :)
things/api.py
Outdated
unconfirmed_overdue_tasks = tasks( | ||
start_date=False, | ||
deadline="past", | ||
start="Anytime", |
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.
Wouldn't Inbox
and Someday
be possible too? Maybe the start is irrelevant here.
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.
ping @AlexanderWillner ; see earlier comment further above which wasn't resolved yet.
return { | ||
None: "", | ||
False: f"AND {column} IS NULL", | ||
True: f"AND {column} IS NOT NULL", | ||
}.get(value, default) | ||
|
||
|
||
def make_date_filter(date_column, offset): | ||
def make_date_filter(date_column: str, offset) -> str: |
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 vote for splitting. It seems hard to read, especially for somebody who's never seen this code before.
A date range filter (specified by an offset) and a date filter (True, False, "past", "future) seems more readable for me.
return { | ||
None: "", | ||
False: f"AND {column} IS NULL", | ||
True: f"AND {column} IS NOT NULL", | ||
}.get(value, default) | ||
|
||
|
||
def make_date_filter(date_column, offset): | ||
def make_date_filter(date_column: str, offset) -> str: |
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.
One can always merge again if it seems too redundant. I much prefer many smaller functions.
@mikez long discussions here ;) remind me: is there something open? |
things/api.py
Outdated
- `deadline == None` (default), then include all tasks. | ||
|
||
deadline_suppressed : bool or None, optional | ||
- `deadline_suppressed == True`, only include tasks with a overdue deadline |
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.
- "with an overdue deadline"
- might need more explanation: "deadline suppressed" is a technical term used in the database. It means overdue tasks which have been moved from Today to Inbox, Anytime, or Someday.
things/api.py
Outdated
- `deadline_suppressed == True`, only include tasks with a overdue deadline | ||
that have been moved from the today view (Inbox, Anytime, Someday). | ||
- `deadline_suppressed == False`, only include tasks with an overdue deadline | ||
that have not been moved from the today view to another view (Inbox, Anytime, Someday). |
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.
Are only tasks with overdue deadlines included or all tasks no matter if their deadline is overdue or not?
things/api.py
Outdated
unconfirmed_overdue_tasks = tasks( | ||
start_date=False, | ||
deadline="past", | ||
start="Anytime", |
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.
ping @AlexanderWillner ; see earlier comment further above which wasn't resolved yet.
return { | ||
None: "", | ||
False: f"AND {column} IS NULL", | ||
True: f"AND {column} IS NOT NULL", | ||
}.get(value, default) | ||
|
||
|
||
def make_date_filter(date_column, offset): | ||
def make_date_filter(date_column: str, offset) -> str: |
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 break it out into a separate PR?
The proposal was to rename make_date_filter
to make_date_range_filter
, but leave it as-is. Then, to add a new function called make_date_filter
which operates on True, False, None, "future", "past"
.
@mikez let us finish this pull request ;) |
@AlexanderWillner Thanks for your patience. I hope to get back to this PR ASAP. |
@AlexanderWillner Well done. I'll satisfy my need for order and readability in an upcoming pull request. |
Thanks. Does it? You changed a few things (for the better) in #83 - good work ;) |
No description provided.