Everytime this hook_cron function kicks off, it appears to be returning 500 rows of data from the api which is taking upwards of 20 sec to execute. Is the $last_sync variable supposed to help limit that in anyway? It appears to be read and updated, but I don't see where in the code or api query it's used.

 242   // Running the sync can take a long time. Only process videos since last sync.
 243   $sync_time = REQUEST_TIME;
 244   $last_sync = variable_get('ooyala_last_sync', 0);
 245 
 246   // Pull from Ooyala all videos that have been updated since last run.
 247   $videos = ooyala_api_video_query(array('orderBy' => 'updatedAt,asc', 'fields' => 'labels'));
 248   ooyala_sync_pull_videos($videos);
 249 
 250   // Set the sync time so that we don't need to process unchanged videos.
 251   variable_set('ooyala_last_sync', $sync_time);

Thanks

CommentFileSizeAuthor
#4 ooyala_cron_latest.patch753 bytesquicksketch

Comments

torgospizza’s picture

500 items is the default max number of items returned by the Ooyala API. I think the best solution here would be to pass that in as an argument (and let it be configurable by an admin).

mlee11111’s picture

Thanks for the quick reply.

Should ooyala_api_video_query() somehow use $last_sync to also limit items back?

torgospizza’s picture

Yeah, it seems like $last_sync should be added to the video query in some way, so that it only pulls videos that have been updated since that last timestamp. After looking at the Ooyala API docs the resulting URL will need to be something like this (for V2):

[GET] /v2/assets?where=time_restrictions.start_date<='2011-06-01T00:00:00Z'+AND+time_restrictions.end_date>='2011-06-01T01:00:00Z'

More examples: http://support.ooyala.com/developers/documentation/reference/query.html

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new753 bytes

This is silly. Looks like it must have been broken in the upgrade from the v1 API. If we don't have the WHERE clause in there then we could end up never processing new videos because we'll never get past the first 500 videos.

This patch corrects the problem, applied to the 2.x branches of both D6 and D7. I'll be making new recommended releases.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.