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

Feature/export #213

Merged
merged 13 commits into from
Feb 14, 2021
Merged

Conversation

IdanPelled
Copy link
Contributor

Export the uses calendar with one click!

Copy link
Contributor

@sagizaidor sagizaidor left a comment

Choose a reason for hiding this comment

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

פיצ'ר חשוב ומגניב

app/routers/export.py Outdated Show resolved Hide resolved
"""filter events by a time frame."""

yield from (
event for event in events
if start <= event.start.date() <= end
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

למה לא לצמצם את הפונקציות האלה לאחת בעזרת ארגומנט ברירת מחדל?

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand what @sagizaidor meant, but I do think it's actually a good idea to export this long statement to a separate function :)

@@ -51,8 +51,8 @@ def yesterday_event(sender: User, session: Session) -> Event:
return create_event(
db=session,
title='event 3',
start=today_date - timedelta(hours=8),
end=today_date,
start=today_date - timedelta(days=1, hours=8),
Copy link
Contributor

Choose a reason for hiding this comment

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

לא בטוח במאה אחוז במה שאני אומר - אבל לשנות פיקסטור שעוד בדיקות משתמשות בו מרגיש לי לא נכון.
מניח שעברת את כל הבדיקות אם עשית את זה וזה עובד. אבל בכל זאת תפס את תשומת ליבי

Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Very good job! We have a bit of additional work to do :)

"""filter events by a time frame."""

yield from (
event for event in events
if start <= event.start.date() <= end
if (
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand what @sagizaidor meant, but I do think it's actually a good idea to export this long statement to a separate function :)

"""filter events by a time frame."""

yield from (
event for event in events
Copy link
Member

Choose a reason for hiding this comment

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

Probably can be in a single line(?)

def get_attendees_email(session: Session, event: Event):
return (session.query(User.email).join(UserEvent)
.filter(UserEvent.events == event).all())
# return (session.query(User.email).join(UserEvent)
Copy link
Member

Choose a reason for hiding this comment

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

Commented code

app/routers/export.py Outdated Show resolved Hide resolved
@@ -55,6 +55,7 @@ def send_in_app_invitation(
session.add(Invitation(recipient=recipient, event=event))

else:
print(recipient.email, event.owner.email)
Copy link
Member

Choose a reason for hiding this comment

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

Use logger instead :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad, it was there only for debugging

@codecov-io
Copy link

codecov-io commented Feb 11, 2021

Codecov Report

Merging #213 (fc1c55c) into develop (9724685) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #213      +/-   ##
===========================================
+ Coverage    99.04%   99.06%   +0.01%     
===========================================
  Files           50       51       +1     
  Lines         2310     2350      +40     
===========================================
+ Hits          2288     2328      +40     
  Misses          22       22              
Impacted Files Coverage Δ
app/main.py 96.66% <ø> (ø)
app/internal/agenda_events.py 100.00% <100.00%> (ø)
app/internal/export.py 100.00% <100.00%> (ø)
app/routers/calendar_grid.py 100.00% <100.00%> (ø)
app/routers/event.py 97.35% <100.00%> (+0.03%) ⬆️
app/routers/export.py 100.00% <100.00%> (ø)
app/routers/share.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9724685...fc1c55c. Read the comment docs.

Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

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

Great job! Probably near the end of it. Added few insights.

start: Union[None, date] = None,
end: Union[None, date] = None,
) -> Iterator[Event]:
"""Returns all events in a time frame.
Copy link
Member

Choose a reason for hiding this comment

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

Blank line after this line

)
for example:
if start_date = None and end_date = datetime.now().date,
then the function will return all events that ends before end_date."""
Copy link
Member

Choose a reason for hiding this comment

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

When closing the docstring, """ should be in a separate line

then the function will return all events that ends before end_date."""

for event in events:
if start and end:
Copy link
Member

Choose a reason for hiding this comment

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

Outside the for, define:

start = start or datetime.date.min
end = end or datetime.date.max

Inside the for, use:

if start <= event.start.date() <= end:
    yield event

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great advice, thanks!

user_id: int, db: Session
) -> Iterator[Event]:
"""Yields all user's events in a time frame."""

Copy link
Member

Choose a reason for hiding this comment

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

Prefer not having a blank line after function's docstring

app/routers/export.py Outdated Show resolved Hide resolved
Comment on lines 49 to 50
"""Creates an ical event,
and adds the event information"""
Copy link
Member

Choose a reason for hiding this comment

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

Join to a single line

def create_ical_event(user_event):
"""Creates an ical event,
and adds the event information"""

Copy link
Member

Choose a reason for hiding this comment

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

Remove the blank line here

app/internal/export.py Show resolved Hide resolved
@yammesicka yammesicka merged commit b9061ec into PythonFreeCourse:develop Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants