Skip to content
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

Refactor #60

Merged
merged 19 commits into from
Aug 12, 2021
Merged

Refactor #60

merged 19 commits into from
Aug 12, 2021

Conversation

IgorFroehner
Copy link
Contributor

@IgorFroehner IgorFroehner commented Jul 7, 2021

This PR Fixes #56 and fixes #58

Refactor the code

  • separate to multiple files and objects (1 for Google communication, 1 for event object, 1 for logic etc..)
    it would be great to have some feedback in this part of PR
  • move logic and boilerplate code to functions, make the code easier to read
  • fix PEP incompatibilities
  • resolve the bug of issue Long-lasting Focus/Highlight Color #58
    the event is urgent if it begins in five minutes and if it hasn't passed 5 minutes it started

Sorry by the large commit, I was changing a lot and all of this is a requirement to the others.

@IgorFroehner IgorFroehner marked this pull request as ready for review July 7, 2021 18:27
@rosenpin
Copy link
Owner

Thanks for the PR

I'll look into it soon and if all looks good I'll merge it next week :)

Copy link
Owner

@rosenpin rosenpin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all - Thank You.

I really liked what you did here, it's already better than what it was previously.

I did leave a few notes that I think could make this project more maintainable and more professional.

If you don't have the time/don't want to implement those notes, that's understandable, my bad for taking so long with the CR.
Anyway I would be glad if you could let me know if you're up for it, if you're not interested I'll take it from here when I get the chance :)

i3_agenda/__init__.py Outdated Show resolved Hide resolved
@@ -0,0 +1,49 @@

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better, instead of having a "utils" file, to have an EventFetcher class, with the get_closest method and get_events method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I agree that there is a better solution that this "utils" file, but just to understand it better:

  • is_allday could be a Event method
  • get_event_time, as commented bellow, and get_closest I see as functions, so I propose to these functions only be moved to the event.py file as separated functions

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant here is that instead of having the get_closest and get_events as functions, we could have an object called EventFetcher and add those functions as its methods

i3_agenda/event_utils.py Outdated Show resolved Hide resolved
i3_agenda/event_utils.py Outdated Show resolved Hide resolved
i3_agenda/API.py Outdated Show resolved Hide resolved
i3_agenda/API.py Outdated Show resolved Hide resolved
i3_agenda/API.py Show resolved Hide resolved
i3_agenda/cache_utils.py Outdated Show resolved Hide resolved
@IgorFroehner
Copy link
Contributor Author

Did some changes, I think most of them it is better, the reply of the reviews will help in next improvements.

And yes I am up with this yet, just give some feedbacks and I can address it.

i3_agenda/event.py Outdated Show resolved Hide resolved
i3_agenda/API.py Outdated Show resolved Hide resolved
@rosenpin
Copy link
Owner

rosenpin commented Aug 9, 2021

Did some changes, I think most of them it is better, the reply of the reviews will help in next improvements.

And yes I am up with this yet, just give some feedbacks and I can address it.

Great! I left some comments, let me know what you think.
I will continue this review tomorrow :)
And thanks again 😄

i3_agenda/API.py Outdated Show resolved Hide resolved
i3_agenda/API.py Outdated Show resolved Hide resolved
i3_agenda/event.py Outdated Show resolved Hide resolved
i3_agenda/event.py Outdated Show resolved Hide resolved
@rosenpin
Copy link
Owner

Thanks again very much for the changes, you did a great job on pretty much everything
I gave some feedback and left some minor comments, there are still the issues we already talked about like the static constructor and the allday issue 😄

@IgorFroehner
Copy link
Contributor Author

IgorFroehner commented Aug 10, 2021

Owww man, I thought here and I realised that is possible to infer if the event is all day looking if it begins at midnight of a day and ends at the midnight of the next day. It looks to be working. It solves a lot of problems discussed before. But I changed the name of the variable unix_time to start_time, and it continue to be a float field.

Well but this change of the name of the attribute broke the cache, so it needs a treatment

i3_agenda/event.py Outdated Show resolved Hide resolved
i3_agenda/cache_utils.py Show resolved Hide resolved
i3_agenda/API.py Outdated Show resolved Hide resolved
i3_agenda/API.py Outdated Show resolved Hide resolved
@rosenpin
Copy link
Owner

Looking good!

I think we juts need to figure out the all_day thing and iron out some minor stuff, then we can merge it 😀

@rosenpin
Copy link
Owner

Great!
All looks good, I'll run some tests on it later today or tomorrow, if it works as expected I'll merge it! 😃

@rosenpin rosenpin added the enhancement New feature or request label Aug 11, 2021
@rosenpin

This comment has been minimized.

)
)
except KeyError:
return None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one event couldn't be parsed correctly, should we drop the entire cache or continue trying?
I think dropping the entire cache is fine, just needs a comment saying "One of the items are invalid. Cache must be invalid"


def is_allday(self) -> bool:
time_delta = self.end_time - self.start_time
return self.get_datetime().time() == dt.time(0) and time_delta % 24 == 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth adding a comment on this one since it's not super clear what we're doing here

@rosenpin rosenpin merged commit 0faa4f2 into rosenpin:master Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Long-lasting Focus/Highlight Color refactor
2 participants