From: Art Cancro Date: Tue, 23 Dec 2008 18:29:12 +0000 (+0000) Subject: * Conflict checker loop now stops iterating over existing events when it goes out... X-Git-Tag: v7.86~1680 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=795754b0510b8df56430fba5ea8bc05572b77d31 * Conflict checker loop now stops iterating over existing events when it goes out of scope for the proposed event. Saves a lot of time but it's still taking too long. And we also need to make it timezone aware. --- diff --git a/citadel/modules/calendar/serv_calendar.c b/citadel/modules/calendar/serv_calendar.c index 120493c8b..05504d3a7 100644 --- a/citadel/modules/calendar/serv_calendar.c +++ b/citadel/modules/calendar/serv_calendar.c @@ -870,15 +870,16 @@ void ical_conflicts_phase6(struct icaltimetype t1start, { /* debugging cruft */ - // time_t tt; - // tt = icaltime_as_timet(t1start); - // CtdlLogPrintf(CTDL_DEBUG, "PROPOSED START: %s", ctime(&tt)); - // tt = icaltime_as_timet(t1end); - // CtdlLogPrintf(CTDL_DEBUG, " PROPOSED END: %s", ctime(&tt)); - // tt = icaltime_as_timet(t2start); - // CtdlLogPrintf(CTDL_DEBUG, "EXISTING START: %s", ctime(&tt)); - // tt = icaltime_as_timet(t2end); - // CtdlLogPrintf(CTDL_DEBUG, " EXISTING END: %s", ctime(&tt)); + time_t tt; + tt = icaltime_as_timet(t1start); + CtdlLogPrintf(CTDL_DEBUG, "PROPOSED START: %s", ctime(&tt)); + tt = icaltime_as_timet(t1end); + CtdlLogPrintf(CTDL_DEBUG, " PROPOSED END: %s", ctime(&tt)); + tt = icaltime_as_timet(t2start); + CtdlLogPrintf(CTDL_DEBUG, "EXISTING START: %s", ctime(&tt)); + tt = icaltime_as_timet(t2end); + CtdlLogPrintf(CTDL_DEBUG, " EXISTING END: %s", ctime(&tt)); + /* debugging cruft */ /* compare and output */ @@ -922,6 +923,7 @@ void ical_conflicts_phase5(struct icaltimetype t1start, icalrecur_iterator *ritr = NULL; struct icaldurationtype dur; int num_recur = 0; + int out_of_scope = 0; /* initialization */ strcpy(conflict_event_uid, ""); @@ -970,7 +972,12 @@ void ical_conflicts_phase5(struct icaltimetype t1start, ++num_recur; } - } while ( (rrule) && (!icaltime_is_null_time(t2start)) && (num_recur < MAX_RECUR) ); + if (icaltime_compare(t2start, t1end) < 0) { + CtdlLogPrintf(CTDL_DEBUG, "Went out of scope after %d iterations\n", num_recur); + out_of_scope = 1; + } + + } while ((rrule) && (!icaltime_is_null_time(t2start)) && (num_recur < MAX_RECUR) && (!out_of_scope)); icalrecur_iterator_free(ritr); if (num_recur > 0) CtdlLogPrintf(CTDL_DEBUG, "Iterated over existing event %d times.\n", num_recur); }