-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added new events for new and all saving sessions
- Loading branch information
1 parent
40c9dd6
commit b2b44b5
Showing
11 changed files
with
525 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,20 @@ | ||
def current_saving_sessions_event(current_date, events): | ||
current_event = None | ||
import datetime | ||
from ..api_client.saving_sessions import SavingSession | ||
|
||
def current_saving_sessions_event(current_date: datetime, events: list[SavingSession]) -> SavingSession or None: | ||
if events is not None: | ||
for event in events: | ||
if (event["start"] <= current_date and event["end"] >= current_date): | ||
current_event = { | ||
"start": event["start"], | ||
"end": event["end"], | ||
"duration_in_minutes": (event["end"] - event["start"]).total_seconds() / 60 | ||
} | ||
break | ||
if (event.start <= current_date and event.end >= current_date): | ||
return event | ||
|
||
return current_event | ||
return None | ||
|
||
def get_next_saving_sessions_event(current_date, events): | ||
def get_next_saving_sessions_event(current_date: datetime, events: list[SavingSession]) -> SavingSession or None: | ||
next_event = None | ||
|
||
if events is not None: | ||
for event in events: | ||
if event["start"] > current_date and (next_event == None or event["start"] < next_event["start"]): | ||
next_event = { | ||
"start": event["start"], | ||
"end": event["end"], | ||
"duration_in_minutes": (event["end"] - event["start"]).total_seconds() / 60 | ||
} | ||
if event.start > current_date and (next_event == None or event.start < next_event.start): | ||
next_event = event | ||
|
||
return next_event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.