1.8 Alpha2 API Stats - Pagination

I swear the stats API hates me. Sorry for so many post about it.

When trying to use pagination with Stats we are running into a strange problem. If we set “start” to 1 or 0 and “length” to say 5, we get the expected results. If we set “start” to 2 and “length” to 5 we get a blank return. If we set “start” to 3 or higher and “length” to 5 we get:

Client Exception: Server error: 500
Unexpected error, Please contact support

Log:

18	d6ccfcb	+002016+0020162016-March03-09 2222:March:5454	API	GET	DEBUG		/stats	Storage rollback.
17	d6ccfcb	+002016+0020162016-March03-09 2222:March:5454	API	GET	ERROR		/stats	No displays with View permissions Exception Type: ErrorException
16	d6ccfcb	+002016+0020162016-March03-09 2222:March:5454	API	GET	DEBUG		/stats	No displays with View permissions#0 [internal function]: Slim\Slim::handleErrors(256, 'No displays wit...', 'C:\\wamp\\www\\xib...', 162, Array) #1 C:\wamp\www\xibo18alpha\lib\Controller\Stats.php(162): trigger_error('No displays wit...', 256) #2 [internal function]: Xibo\Controller\Stats->grid() #3 C:\wamp\www\xibo18alpha\vendor\slim\slim\Slim\Route.php(173): call_user_func_array(Array, Array) #4 [internal function]: Slim\Route->Slim\{closure}() #5 C:\wamp\www\xibo18alpha\vendor\slim\slim\Slim\Route.php(468): call_user_func_array(Object(Closure), Array) #6 C:\wamp\www\xibo18alpha\vendor\slim\slim\Slim\Slim.php(1357): Slim\Route->dispatch() #7 C:\wamp\www\xibo18alpha\vendor\slim\slim\Slim\Middleware\Flash.php(85): Slim\Slim->call() #8 C:\wamp\www\xibo18alpha\vendor\slim\slim\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call() #9 C:\wamp\www\xibo18alpha\lib\Middleware\ApiAuthenticationOAuth.php(58): Slim\Middleware\MethodOverride->call() #10 C:\wamp\www\xibo18alpha\lib\Middleware\State.php(102): Xibo\Middleware\ApiAuthenticationOAuth->call() #11 C:\wamp\www\xibo18alpha\lib\Middleware\Storage.php(39): Xibo\Middleware\State->call() #12 C:\wamp\www\xibo18alpha\vendor\slim\slim\Slim\Slim.php(1302): Xibo\Middleware\Storage->call() #13 C:\wamp\www\xibo18alpha\web\api\index.php(95): Slim\Slim->run() #14 {main}
15	d6ccfcb	+002016+0020162016-March03-09 2222:March:5454	API	GET	DEBUG		/stats	SELECT display.displayId, display.display, display.defaultLayoutId, layout.layout AS defaultLayout, display.license, display.licensed, display.licensed AS currentlyLicenced, display.loggedIn, display.lastAccessed, display.isAuditing, display.inc_schedule AS incSchedule, display.email_alert AS emailAlert, display.alert_timeout AS alertTimeout, display.clientAddress, display.mediaInventoryStatus, display.macAddress, display.macAddress AS currentMacAddress, display.lastChanged, display.numberOfMacAddressChanges, display.lastWakeOnLanCommandSent, display.wakeOnLan AS wakeOnLanEnabled, display.wakeOnLanTime, display.broadCastAddress, display.secureOn, display.cidr, X(display.GeoLocation) AS latitude, Y(display.GeoLocation) AS longitude, display.version_instructions AS versionInstructions, display.client_type AS clientType, display.client_version AS clientVersion, display.client_code AS clientCode, display.displayProfileId, display.currentLayoutId, currentLayout.layout AS currentLayout, display.screenShotRequested, display.storageAvailableSpace, display.storageTotalSpace, displaygroup.displayGroupId, displaygroup.description, `display`.xmrChannel, `display`.xmrPubKey, `display`.lastCommandSuccess FROM `display` INNER JOIN `lkdisplaydg` ON lkdisplaydg.displayid = display.displayId INNER JOIN `displaygroup` ON displaygroup.displaygroupid = lkdisplaydg.displaygroupid LEFT OUTER JOIN layout ON layout.layoutid = display.defaultlayoutid LEFT OUTER JOIN layout currentLayout ON currentLayout.layoutId = display.currentLayoutId WHERE 1 = 1 AND displaygroup.isDisplaySpecific = 1 ORDER BY display LIMIT 5, 5
14	d6ccfcb	+002016+0020162016-March03-09 2222:March:5454	API	GET	DEBUG		/stats	Converted Times received are: FromDt=2016-03-08 22:23:54. ToDt=2016-03-31 23:59:59
13	d6ccfcb	+002016+0020162016-March03-09 2222:March:5454	API	GET	DEBUG		/stats	SET @clientId=r6WoHiHLBg2QSQwgl9ur7IrQawyCfO7Wdfxdxdx1; SELECT `user`.userId, userName, userTypeId, loggedIn, email, lastAccessed, newUserWizard, retired, CSPRNG, UserPassword AS password, group.groupId, group.group , `pages`.pageId AS homePageId, `pages`.title AS homePage , `user`.firstName, `user`.lastName, `user`.phone, `user`.ref1, `user`.ref2, `user`.ref3, `user`.ref4, `user`.ref5 , IFNULL(group.libraryQuota, 0) AS libraryQuota FROM `user` INNER JOIN lkusergroup ON lkusergroup.userId = user.userId INNER JOIN `group` ON `group`.groupId = lkusergroup.groupId AND isUserSpecific = 1 LEFT OUTER JOIN `pages` ON pages.pageId = `user`.homePageId WHERE 1 = 1 AND user.userId = (SELECT userId FROM `oauth_clients` WHERE id = @clientId) ORDER BY userName

It looks like the start and size limits are getting use when searching the displays??

Paging isn’t implemented at all for the stats call - you will notice in the UI itself that it doesn’t page either.

You are absolutely right about the start/size variables being used searching displays - that is obviously not correct and has already been solved.

Are there any plans to implement paging on the stats call? This would help us keep our system more consistent in how it looks and works.

I’ll pop in an issue for it:

1 Like