diff --git a/gcalcli/gcal.py b/gcalcli/gcal.py index 65b512d3..2a38ca1e 100644 --- a/gcalcli/gcal.py +++ b/gcalcli/gcal.py @@ -1026,8 +1026,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: @@ -1079,6 +1089,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 ) ) @@ -1091,17 +1105,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'])