def event_by_id_and_date(self, id, date): real = self.catalog.catalog( path={'query': self.catalog.path, 'depth': 1}, object_provides=IEventsDirectoryItem.__identifier__, review_state=self.state, id=id )[0].getObject() # there is currently no way to easily look up the event by date # if it has been split over dates already (which is what happens # when the events are indexed) # therefore we need to currently loop over all events to find the # right one. certainly this can be optimized. # however, tests on a 10k sites with 60% of all events being recurrent # indicate that it's not that big of a problem. spawning events is # quite fast and it only happens for 10 items per request # still, I would prefer some kind of lookup here min_date = date - timedelta(days=1) max_date = date + timedelta(days=1) for item in self.spawn_events([real], min_date, max_date): start = dates.to_utc( dates.delete_timezone(item.local_start) ).replace(second=0, microsecond=0) if start == date: return item assert False, "lookup for %s failed" % id
def event_by_id_and_date(self, id, date): real = self.catalog.catalog( path={ 'query': self.catalog.path, 'depth': 1 }, object_provides=IEventsDirectoryItem.__identifier__, review_state=self.state, id=id)[0].getObject() # there is currently no way to easily look up the event by date # if it has been split over dates already (which is what happens # when the events are indexed) # therefore we need to currently loop over all events to find the # right one. certainly this can be optimized. # however, tests on a 10k sites with 60% of all events being recurrent # indicate that it's not that big of a problem. spawning events is # quite fast and it only happens for 10 items per request # still, I would prefer some kind of lookup here min_date = date - timedelta(days=1) max_date = date + timedelta(days=1) for item in self.spawn_events([real], min_date, max_date): start = dates.to_utc(dates.delete_timezone( item.local_start)).replace(second=0, microsecond=0) if start == date: return item assert False, "lookup for %s failed" % id
def identity(self, event): date = dates.delete_timezone(event.local_start) return '%s;%s' % (date.strftime('%y.%m.%d-%H:%M'), event.id)