Does Connector load all events at once?

Hello,

I have been trying to work out if connector is loading all of my calendars events at once?

When I view the calls to my sources all I can see is scheduler calling:

Do you have an example of how I can limit the events down to the chosen timeframe using the connector method?

Thanks,

Tim

Hello, Tim.

Indeed by default all events are loaded at once which may be a problem if there are a lot of events in database. To avoid this it’s possible to use Dynamical loading. With this option only events in certain time frame will be loaded and cached (new requests will be send when needed).

Best regards,
Ilya

Hello,

Thanks for this.

I have added scheduler.setLoadMode:

scheduler.init("scheduler_here, null, month");
scheduler.setLoadMode("month");
scheduler.load(["source1", "source2", "source3"]);

This works great when the page with the calendar is first loaded. However navigating forwards and backwards (on any view) causes the events to be reloaded in again and again. The same event is ended up being stacked up multiple times in all the views.

My server side has a before render event that adjusts the id’s (i am loading from multiple tables and ids are not unique) by adding a letter code behind the id generated by scheduler:

function my_code($action) {
$newID =  $action->get_value("id");

$action->set_Value("id", $newID."FF");
}

$scheduler->event_attach("beforeRender", "my_code");
$scheduler->render_sql("...");

I have tried disabling this function and this does not resolve the issue.

Appart from loading in multiple sources I am not doing anything else exotic.

Thanks,

Tim

Hello, Tim.

Please attach server side log when you navigate between months

$scheduler->enable_log("log.txt",true);

and full code of your events.php file.

Also can you please check server responses: which request is used (is there start and end dates in get parameters) and what exactly server returns (only events for the current month or all of them)?

Best regards,
Ilya

Hello,

I have been troubleshooting and would like to attach logs but I have to be careful about showing the SQL statements in this public forum. If you have an email I will happily forward everything to you.

The server side log is normal. When toggling between months nothing unusual is seen. One of these events (shown below) is generated for each call.

[code]====================================
Log started, 29/03/2011 09:03:49

SELECT *******

Done in 0.0076320171356201s[/code]
The events file follows this basic structure (sensitive information removed)

[code]function getData()
{

include ('codebase/connector/scheduler_connector.php');

//DB is loaded here::: 	
 	
$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass); 
mysql_select_db($mysql_db); 

$scheduler = new schedulerConnector($res);
$scheduler->enable_log("log.txt",true);

function my_code($action){
$ds = $action->get_value("datestart");
$ts = $action->get_value("timestart");
$de = $action->get_value("dateend");
$te = $action->get_value("timeend");

$newID = $action->get_value("id");

$action->set_value("datestart", $ds." ".$ts);
$action->set_value("dateend", $de." ".$te);
$action->set_value("id", $newID."A");
}

$scheduler->event->attach("beforeRender", "my_code");

$scheduler->render_sql(“SELECT *****”, “id”, “datestart, dateend, title, section_id, type, readonly”);
}[/code]
The calendar is making calls that look like:

However it appears that all events regardless of their dates are being returned. For example with the above call events with:

<start_date>2011-02-19 09:00:00</start_date> <end_date>2011-02-19 17:00:00</end_date>
and

<start_date>2011-04-29 09:00:00</start_date> <end_date>2011-04-29 17:00:00</end_date> <text>THIS EVENT SHOULD NOT APPEAR</text>
were returned.

I hope this provides enough information.

Thanks,

Tim

Hello, Tim.

You can send me your events.php content and full query from the log using private messages.

Here’s the problem:
For example my query to fetch events is following

$scheduler->render_sql("SELECT * FROM events WHERE 1=1", "event_id", "start_date,end_date,event_name,details")

But if I use it with dynamical loading it will be changed to (from logs):

SELECT  * FROM events WHERE  1=1 AND start_date < '2011-06-01' AND end_date > '2011-05-01'

Which will result only in events for that specific month.

In your case, as your database structure differs, such addition to the query doesn’t seem to help and with each query you get all events from the database. As possible solution you may want to use ‘to’ and ‘from’ get parameters yourself in the select query to make it right. This can probably break your insert/update/delete operations (as condition won’t be met), so you will need to use one query for select and another for all other operations. Check Join Tables and Complex Queries Operations page for details.

Best regards,
Ilya

Hello,

Thanks for this. It explains a lot. Unfortunately I am not able to work with GET variables. I can only work with URI strings or POST vars.

Is there anyway I can reformat the call string to something like:

http://localhost/get_data/timeshift/660/from/2011-03-01/to/2011-06-01

I appreciate your help.

PS. This along with my button issue are the 2 last issues I need to resolve before I can purchase scheduler.

Thanks,

Tim

Hello,

Please disregard above message. I will script a GET translator.

Thanks,

Tim

Hello, Tim.

To get such urls you need to work with your web server (enable rewrite urls and specify rules).

By default parameters to load events are sent using GET requests. Yet it’s possible and is quite easy to modify source code so they will be sent using POST.
In uncompressed version line to change is following:

dhtmlxAjax.get(url+"&from="+lf(from)+"&to="+lf(to),function(l){scheduler.on_load(l);});

Change it to:

dhtmlxAjax.post(url,"from="+lf(from)+"&to="+lf(to),function(l){scheduler.on_load(l);});

Best regards,
Ilya

Hello,

Thanks for this.

Loading in the events on demand seems to work fairly reliably. However occasionally it still gets confused and reloads events that already exist. I am using 4 database sources so it could just be the lag from retrieving the sources that is causing it to stumble.

This happens when I am just casually browsing through the calendar/scheduler. Has anyone else noticed this issue?

Thanks,

Tim

Hello,

An update on this issue.

I have only observed this issue occurring in the timeline week view. This issue also only seems to be happening to multiday bookings that span across 2 or more weeks.

Here is how I reproduce the bug:

  1. I load the calendar with the timeline week view. (All events load as normal)
  2. I click forward one week in the same timeline week view. (The two events that spanned from the previous week load again causing them to be duplicated).
  3. All other events remain ok.

I think that as the events span across 2 weeks the scheduler is not recognizing them as already loaded when the next week is loaded.

Thanks,

Tim

Hello,

I am trying to provide more information on this event duplication issue.

Facts:

  1. This only happens on “Timeline” views.
  2. This only happens if the timeline is viewed first on a fresh page load. If the calendar has already been cycled through the other views this does not cause the error to occur as the events have already been cached.

Below is my code for generating my weekly view of the timeline.

scheduler.date.timeline_start = scheduler.date.week_start; scheduler.createTimelineView({ section_autoheight: false, name: "timeline", x_unit: "day", x_date: "%D, %F %j", x_step: 1, x_size: 7, x_start: 0, x_length: 0, y_unit: elements, y_property: "section_id", render: "tree", folder_dy:20, dy:20 });
Thanks,

Tim

Hello,

We have resolved this issue via support system but for the future references — problem was in using auto generated ids for events instead of table values. So the same event but with new id was loaded and it was treated by scheduler as completely new event.

Best regards,
Ilya