Skip to content

Commit

Permalink
Merge pull request #664 from kbulygin/master
Browse files Browse the repository at this point in the history
fix event list: configure all page queries, not just the first one
  • Loading branch information
dbarnett authored Aug 26, 2024
2 parents cec6f25 + 048f6ec commit 3fa9701
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions gcalcli/gcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,18 @@ def _iterate_events(self, start_datetime, event_list, year_date=False,

return selected

def _GetAllEvents(self, cal, events, end):

def _GetAllEvents(self, cal, start, end, search_text):
events = self._retry_with_backoff(
self.get_events()
.list(
calendarId=cal['id'],
timeMin=start.isoformat() if start else None,
timeMax=end.isoformat() if end else None,
q=search_text if search_text else None,
singleEvents=True
)
)

event_list = []

while 1:
Expand Down Expand Up @@ -1078,6 +1088,10 @@ def _GetAllEvents(self, cal, events, end):
self.get_events()
.list(
calendarId=cal['id'],
timeMin=start.isoformat() if start else None,
timeMax=end.isoformat() if end else None,
q=search_text if search_text else None,
singleEvents=True,
pageToken=pageToken
)
)
Expand All @@ -1090,17 +1104,7 @@ def _search_for_events(self, start, end, search_text):

event_list = []
for cal in self.cals:
events = self._retry_with_backoff(
self.get_events()
.list(
calendarId=cal['id'],
timeMin=start.isoformat() if start else None,
timeMax=end.isoformat() if end else None,
q=search_text if search_text else None,
singleEvents=True
)
)
event_list.extend(self._GetAllEvents(cal, events, end))
event_list.extend(self._GetAllEvents(cal, start, end, search_text))

event_list.sort(key=lambda x: x['s'])

Expand Down

0 comments on commit 3fa9701

Please sign in to comment.