[evolution-patches] Evolution calendar get_object_query optimizations



hi,

 The proposed patch cuts down redundant get_object_list queries to eds,
during operations like initial loading, switching b/w views and dates
etc. On GW accounts, this appears to solve the GUI hanging problems, at
least in the limited scenarios we (me and chen) have tested so far. In
some of the scenarios tested, as many as 60 queries on a GW account were
reduced to a single query.

This may also be a solution for #59904 and the bugs resolved as its
duplicates - though the regression has not been done yet.

thanks,
harish


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2554
diff -u -p -r1.2554 ChangeLog
--- ChangeLog	21 Oct 2004 17:07:23 -0000	1.2554
+++ ChangeLog	25 Oct 2004 14:34:54 -0000
@@ -1,3 +1,20 @@
+2004-10-25  Harish Krishnaswamy  <kharish novell com>
+            Chenthill Palanisamy <pchenthill novell com>	
+ 	
+	* gui/e-cal-model.c: (e_cal_view_objects_added_cb):
+	use e_cal_recur_generate_instances directly instead of
+	e_cal_generate_instances_for_object. This achieves the
+	needful without multiple queries to the backend.
+	* gui/e-day-view.c: (process_component):
+	same change as above for recurring items. For non-recur items,
+	call e_day_view_add_event directly.
+	* gui/e-week-view.c: (process_component):
+	same change as above for recurring items. For non-recur items,
+	call e_week_view_add_event directly.
+	* gui/tag-calendar.c: (tag_calendar_by_comp):
+	use e_cal_recur_generate_instances directly instead of
+	e_cal_generate_instances_for_object.
+
 2004-10-21  Harish Krishnaswamy  <kharish novell com>
 
 	* gui/e-cal-popup.[ch]: (e_cal_popup_target_new_source):
Index: gui/e-cal-model.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-model.c,v
retrieving revision 1.46
diff -u -p -r1.46 e-cal-model.c
--- gui/e-cal-model.c	14 Oct 2004 15:22:32 -0000	1.46
+++ gui/e-cal-model.c	25 Oct 2004 14:34:55 -0000
@@ -1337,6 +1337,7 @@ e_cal_view_objects_added_cb (ECalView *q
 	ECalModel *model = (ECalModel *) user_data;
 	ECalModelPrivate *priv;
 	GList *l;
+	ECalComponent *comp;
 
 	priv = model->priv;
 
@@ -1349,10 +1350,11 @@ e_cal_view_objects_added_cb (ECalView *q
 			rdata.query = query;
 			rdata.model = model;
 			rdata.icalcomp = l->data;
-			e_cal_generate_instances_for_object (rdata.client, l->data,
-							     priv->start, priv->end,
-							     (ECalRecurInstanceFn) add_instance_cb,
-							     &rdata);
+			comp = e_cal_component_new ();
+			e_cal_component_set_icalcomponent (comp, l->data);
+			e_cal_recur_generate_instances (comp, priv->start, priv->end, add_instance_cb, &rdata,
+					e_cal_resolve_tzid_cb, rdata.client, priv->zone);
+
 		} else {
 			ECalModelComponent *comp_data;
 
Index: gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.256
diff -u -p -r1.256 e-day-view.c
--- gui/e-day-view.c	19 Oct 2004 16:20:07 -0000	1.256
+++ gui/e-day-view.c	25 Oct 2004 14:34:56 -0000
@@ -509,7 +509,10 @@ process_component (EDayView *day_view, E
 	const char *uid;
 	ECalComponent *comp;
 	AddEventData add_event_data;
-
+	ECalModel *model;
+	icaltimezone *default_timezone;
+	time_t start, end;
+	
 	/* If our time hasn't been set yet, just return. */
 	if (day_view->lower == 0 && day_view->upper == 0)
 		return;
@@ -566,9 +569,42 @@ process_component (EDayView *day_view, E
 	/* Add the occurrences of the event */
 	add_event_data.day_view = day_view;
 	add_event_data.comp_data = comp_data;
-	e_cal_generate_instances_for_object (comp_data->client, comp_data->icalcomp, day_view->lower,
-					     day_view->upper,
-					     e_day_view_add_event, &add_event_data);
+	
+	model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+	default_timezone = e_cal_model_get_timezone (model);
+	if (e_cal_component_has_recurrences (comp))
+		e_cal_recur_generate_instances (comp, day_view->lower,  day_view->upper, e_day_view_add_event, &add_event_data, e_cal_resolve_tzid_cb, comp_data->client, default_timezone);
+
+	else {
+		icaltimezone *start_zone = NULL, *end_zone = NULL;
+		ECalComponentDateTime dtstart, dtend;
+			
+		e_cal_component_get_dtstart (comp, &dtstart);
+		e_cal_component_get_dtend (comp, &dtend);
+
+		if (dtstart.tzid && !dtstart.value->is_date) {
+			if (!e_cal_get_timezone (comp_data->client, dtstart.tzid, &start_zone, NULL)) 
+				start_zone = default_timezone;
+		} else 
+			start_zone = default_timezone;
+
+	
+		start = icaltime_as_timet_with_zone (*dtstart.value,
+						    start_zone);
+
+		if (dtend.tzid && !dtend.value->is_date) {
+			if (!e_cal_get_timezone (comp_data->client, dtend.tzid, &end_zone, NULL)) 
+				end_zone = default_timezone;
+		} else
+			end_zone = default_timezone;
+		
+		end = icaltime_as_timet_with_zone (*dtend.value, end_zone);
+
+		if ( start < day_view->upper && end > day_view->lower) {
+			e_day_view_add_event (comp, start, end, &add_event_data);
+		}
+
+	}
 
 	g_object_unref (comp);
 }
Index: gui/e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.227
diff -u -p -r1.227 e-week-view.c
--- gui/e-week-view.c	14 Oct 2004 14:56:18 -0000	1.227
+++ gui/e-week-view.c	25 Oct 2004 14:34:57 -0000
@@ -318,6 +318,9 @@ process_component (EWeekView *week_view,
 	ECalComponent *comp = NULL;
 	AddEventData add_event_data;
 	const char *uid;
+	ECalModel *model;
+	icaltimezone *default_timezone;
+	time_t start, end;
 
 	/* If we don't have a valid date set yet, just return. */
 	if (!g_date_valid (&week_view->first_day_shown))
@@ -374,11 +377,40 @@ process_component (EWeekView *week_view,
 
 	add_event_data.week_view = week_view;
 	add_event_data.comp_data = comp_data;
-	e_cal_generate_instances_for_object (comp_data->client, comp_data->icalcomp,
-					     week_view->day_starts[0],
-					     week_view->day_starts[num_days],
-					     process_component_recur_cb, &add_event_data);
+	model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+	default_timezone = e_cal_model_get_timezone (model);
+	if (e_cal_component_has_recurrences (comp))
+		e_cal_recur_generate_instances (comp, week_view->day_starts[0],  week_view->day_starts[num_days], process_component_recur_cb, &add_event_data, e_cal_resolve_tzid_cb, comp_data->client, default_timezone);
+	else {
+		icaltimezone *start_zone = NULL, *end_zone = NULL;
+		ECalComponentDateTime dtstart, dtend;
+			
+		e_cal_component_get_dtstart (comp, &dtstart);
+		e_cal_component_get_dtend (comp, &dtend);
+
+		if (dtstart.tzid && !dtstart.value->is_date) {
+			if (!e_cal_get_timezone (comp_data->client, dtstart.tzid, &start_zone, NULL)) 
+				start_zone = default_timezone;
+		} else 
+			start_zone = default_timezone;
+
+	
+		start = icaltime_as_timet_with_zone (*dtstart.value,
+						    start_zone);
+
+		if (dtend.tzid && !dtend.value->is_date) {
+			if (!e_cal_get_timezone (comp_data->client, dtend.tzid, &end_zone, NULL)) 
+				end_zone = default_timezone;
+		} else
+			end_zone = default_timezone;
+		
+		end = icaltime_as_timet_with_zone (*dtend.value, end_zone);
 
+		if ( start < week_view->day_starts[0] && end > week_view->day_starts [num_days]) {
+			e_week_view_add_event (comp, start, end, FALSE, &add_event_data);
+		}
+
+	}
 	g_object_unref (comp);
 }
 
Index: gui/tag-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/tag-calendar.c,v
retrieving revision 1.24
diff -u -p -r1.24 tag-calendar.c
--- gui/tag-calendar.c	20 May 2004 18:41:36 -0000	1.24
+++ gui/tag-calendar.c	25 Oct 2004 14:34:57 -0000
@@ -213,14 +213,8 @@ tag_calendar_by_comp (ECalendar *ecal, E
 #if 0
 	g_print ("DateNavigator generating instances\n");
 #endif
-	if (comp_is_on_server) {
-		e_cal_generate_instances_for_object (client, e_cal_component_get_icalcomponent (comp),
-						     c.start_time, c.end_time,
-						     tag_calendar_cb, &c);
-	} else {
-		e_cal_recur_generate_instances (comp, c.start_time, c.end_time,
+	e_cal_recur_generate_instances (comp, c.start_time, c.end_time,
 						tag_calendar_cb, &c,
-						resolve_tzid_cb,
+						(comp_is_on_server ? e_cal_resolve_tzid_cb : resolve_tzid_cb),
 						client, c.zone);
-	}
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]