-
Notifications
You must be signed in to change notification settings - Fork 3
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
Things.py Refactor #2
Conversation
@mikez Wow, this is very generous of you! Sorry I'm only seeing this now. I'll take a look when I'm able, and see if it makes sense for me. I truly appreciate it. |
@mikez I'm starting to test this merge, and I'm not getting results. Example of the "Today" query, which boils down to just the following, is returning zero results:
|
@chrisgurney Glad to see you playing around with it! Let's debug together. First: >>> import things
>>> things.today() is this working? You can see the source of it here. It first does a regular fetch for tasks with start="Anytime" (today's items tend to be there), see also terminology here. Then it does two "predictive" fetches for tasks that would end up there once Things.app opened for the day. |
@mikez Excellent, that pointer to the source helped a lot with selecting the proper I do see that "Evening" tasks are at the top of the list, whereas if you add an I attempted to do a Have you looked into understanding and/or adding support for the If I can figure out the source, I'm tempted to take a stab at a PR, but will likely need assistance, I'm sure. :-) |
@chrisgurney I was not aware of startBucket before; that sounds like a great addition! To clarify (asking out loud): what does I see three options so far:
What do you think? |
@mikez In my limited testing when looking at the Today list, when moving a task between Evening and not-the-Evening (and vice-versa) the I also tried moving tasks around in Anytime and Someday (i.e., other Given the above, I do like solution 1, where you suggested "evening: True". However, if Cultured Code is thinking of adding other If I put my DB design hat on, it makes me wonder why they chose the generic "bucket", versus just using an "evening" flag. But that may be because "Evening" wouldn't apply to most tasks, and wanted to leave it open to other uses in the future. This leads me back to thinking that an enum might be a safer bet. Thoughts? 😄 |
FYI you should know I'm relatively new to Python (not sure if that was obvious looking at my code), so your knowledge of the appropriate data structures to solve this will most definitely exceed mine. 😅 |
@chrisgurney Thank you for the analysis! I took a look at the guiding design principle I chose back in the day:
As much as I would have loved Would you enjoy to give a PR a shot? Note there's a database in the
Welcome to Python! 🐍 What programming languages are you most familiar with? |
@mikez Thanks for the feedback! I'll put some thought into the start_bucket PR when I'm able -- I'm looking forward to contributing to my first OSS project! In other news, I've got what I think are all the use cases for 🧑💻 I went to school back when Java was just arriving on the scene, so got into that and then J2EE. At the time I used PHP for personal projects. In more recent years, I've been getting into React (for working with design systems as a UX designer), and now Python for personal projects (mostly for scripting and static site generation). Thanks again for the help with future-proofing my lowly personal utility script. 😄 |
@chrisgurney As soon as you have some code, feel free to submit a PR request, and we can take it from there. |
Looking through your code, note that in the API you can do
Although, I normally call |
Oh that's much cleaner than all those date calculations. I'll take a look to see if that works for me. Thanks! |
Hey @mikez I could use your help: I'm adding an argument to Example: I'm looking for all tasks completed on Code:
Here's the
IF things.py doesn't support time zone adjustments, how would you do a query like this? Thanks! |
@mikez I've added support for the I'll update here if I figure out any workarounds. Thinking of: getting tasks completed on the date provided and the next day's, then filtering the returned task times against the local time. |
@chrisgurney I hope to take a closer look at your question Monday or Tuesday. |
Appreciate it, thanks! |
@mikez Update: I think I have a fix in place (given my workaround noted previously) but it's anything but elegant. |
@chrisgurney I took a look. I think you spotted a bug, or rather, something that wasn't thought of yet amidst the recent date updates. Currently:
The database itself stores these dates as UTC. Suggested ChangesMake both responses and queries be in localtime. What do you think? To do so, tweak these functions in database.py of things.py:
Want to give it a shot? Hopefully, these should be easy edits and not involve much more than adding "localtime" to the SQL-query, i.e., Let me know if you have any questions; happy to guide. |
Hey @mikez thanks for following up! Just yesterday I went through a similar issue with PyGithub and had to implement the same workaround. You might want to take a look through this thread to see if this changes your thinking at all. My main concern would be: Is this a breaking change for implementers of I've almost implemented my own workaround in |
Thank you for the the link to the thread and proposals. I pondered a bit. :) Two UX questions:
|
Some Python tricks (looking at your code): >>> import datetime
>>> first_datetime = datetime.datetime.today()
>>> first_datetime.date().isoformat()
'2024-03-01'
>>> stop_date = '2024-03-10'
>>> datetime.date.fromisoformat(stop_date)
datetime.date(2024, 3, 1) (Similar methods exist for dates with times and timezones.) |
Hey @mikez, thanks for checking in. I'm in the middle of re-writing In terms of use cases, I can only speak for what my own users of I suspect that the users of those projects are assuming their local time is applied (and haven't spotted the issue), or those projects have implemented their own workarounds. More thoughts re: Strings:
|
As for times:
|
@mikez Quick update: Hoping to look at this soon! |
If you have any questions, feel free to post here and I will respond.