Update: Or maybe that is not the problem. I tried the following code and it also seemed to return an empty array. I do see a 200 response in the returned header.
Update 2: Tried to pull up the stats in the CMS 1.8 Alpha, and it also is blank. I manually checked the database and there is tons of data in there.
In addition to this we are also having trouble with the Displays api. No matter what we enter it always returns every display. In the CMS if we try and search by name no matter what we enter it returns nothing.
At the moment filter_display in the query will get you a filter by display name. This needs rationalising across all GET calls so that the parameters are named as per the object they relate to - in this case it should be “display”
You may need to enable test mode and pull out the SQL it is running to see what’s wrong.
Enabled Test mode and went Display - Manage. We started seeing this under “Errors in the Last 12 hours”:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'xml' in 'field list'
I have the collect and save data too if it helps. It is too big to fit here.
I wonder if the data I am seeing in the database is simply the download stats and what not, and there is really nothing about the proof of display being recorded, which is why we get an empty array back from the API when calling the stats.
I tried that… I got 5 pages of SQL logs. Not sure why that is yet, maybe our script.
UPDATE: CMS log after trying to return stats via the API:
12 fb8cef0 2015-10-23 21:42 WEB GET DEBUG SQL = SELECT ModuleID, Module, Name, Enabled, Description, render_as, settings, RegionSpecific, ValidExtensions, ImageUri, PreviewEnabled, assignable, SchemaVersion, viewPath, `class` FROM `module` WHERE 1 = 1 ORDER BY Module. Params = array ( ).
11 4ee5ee7 2015-10-23 21:42 API GET DEBUG /stats SQL = 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 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. Params = array ( ).
10 4ee5ee7 2015-10-23 21:42 API GET DEBUG /stats Converted Times received are: FromDt=2015-10-22 21:42:08. ToDt=2015-10-23 21:42:08
9 4ee5ee7 2015-10-23 21:42 API GET DEBUG /stats SQL = SELECT `group`.group, `group`.groupId, `group`.isUserSpecific, `group`.isEveryone, `group`.libraryQuota FROM `group` WHERE 1 = 1 AND `group`.groupId IN (SELECT groupId FROM `lkusergroup` WHERE userId = :userId) AND isUserSpecific = :isUserSpecific AND isEveryone = :isEveryone . Params = array ( 'userId' => 1, 'isUserSpecific' => 0, 'isEveryone' => 0, ).
8 4ee5ee7 2015-10-23 21:42 API GET DEBUG /stats Loading 1. All Objects = 0
7 4ee5ee7 2015-10-23 21:42 API GET DEBUG /stats SQL = SELECT `user`.userId, userName, userTypeId, loggedIn, email, `user`.homePageId, pages.title AS homePage, lastAccessed, newUserWizard, retired, CSPRNG, UserPassword AS password, group.groupId, group.group, 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 = :userId ORDER BY userName. Params = array ( 'userId' => 1, ).
If we run the sql of id 7 and 9 from the log in phpMyAdmin we get errors like this:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':userId ORDER BY userName'
Which made us look at this from the log:
ID 7
:userId
Traced to line 188 in lib/Factory/UserFactory.php
Also…
Applied and still getting:
286 2015-10-24 00:22 SQLSTATE[42S22]: Column not found: 1054 Unknown column 'xml' in 'field list'
Regarding logs - you can identify the log messages in all unique call using the Run Number - in the case above 4ee5ee7 is associated with your API call.
Unfortunately the main query isn’t logged, you can add a line on 212: Log::sql($sql, $params) to get that SQL out.
Regarding the SQL statements in the logs - they have a text SQL string and then a parameters array - you will need to manually substitute the :param with the parameter value from the parameters array, in your example :userId is 1.
Awesome. No worries on the time factor, after all it is a developing project.
I will see about trying out the changes and see what happens.
Update: Made the changes. Tried the date filter again and still nothing on the return but an empty array.
Log:
12 3f7f247 2015-11-05 20:28 API GET DEBUG /stats SQL = SELECT stat.type, display.Display, layout.Layout, IFNULL(widgetoption.value, CONCAT(widget.type, '-', widget.widgetId)) AS Name, COUNT(StatID) AS NumberPlays, SUM(TIME_TO_SEC(TIMEDIFF(end, start))) AS Duration, MIN(start) AS MinStart, MAX(end) AS MaxEnd FROM stat INNER JOIN display ON stat.DisplayID = display.DisplayID INNER JOIN layout ON layout.LayoutID = stat.LayoutID LEFT OUTER JOIN `widget` ON `widget`.widgetId = stat.MediaID LEFT OUTER JOIN `widgetoption` ON `widgetoption`.widgetId = `widget`.widgetId AND `widgetoption`.type = 'attrib' AND `widgetoption`.option = 'name' WHERE stat.type <> 'displaydown' AND stat.end > :fromDt AND stat.start <= :toDt AND stat.displayID IN (2,1) GROUP BY stat.type, display.Display, layout.Layout, CONCAT(widget.type, '-', widget.widgetId) ORDER BY stat.type, display.Display, layout.Layout, Name . Params = array ( 'fromDt' => Jenssegers\Date\Date::__set_state(array( 'date' => '2015-11-04 20:28:32', 'timezone_type' => 3, 'timezone' => 'America/Los_Angeles', )), 'toDt' => Jenssegers\Date\Date::__set_state(array( 'date' => '2015-11-05 20:28:32', 'timezone_type' => 3, 'timezone' => 'America/Los_Angeles', )), ).
11 3f7f247 2015-11-05 20:28 API GET DEBUG /stats SQL = 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 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. Params = array ( ).
10 3f7f247 2015-11-05 20:28 API GET DEBUG /stats Converted Times received are: FromDt=2015-11-04 20:28:32. ToDt=2015-11-05 20:28:32
9 3f7f247 2015-11-05 20:28 API GET DEBUG /stats SQL = SELECT `group`.group, `group`.groupId, `group`.isUserSpecific, `group`.isEveryone, `group`.libraryQuota FROM `group` WHERE 1 = 1 AND `group`.groupId IN (SELECT groupId FROM `lkusergroup` WHERE userId = :userId) AND isUserSpecific = :isUserSpecific AND isEveryone = :isEveryone . Params = array ( 'userId' => 1, 'isUserSpecific' => 0, 'isEveryone' => 0, ).
8 3f7f247 2015-11-05 20:28 API GET DEBUG /stats Loading 1. All Objects = 0
7 3f7f247 2015-11-05 20:28 API GET DEBUG /stats SQL = SELECT `user`.userId, userName, userTypeId, loggedIn, email, `user`.homePageId, pages.title AS homePage, lastAccessed, newUserWizard, retired, CSPRNG, UserPassword AS password, group.groupId, group.group, 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 = :userId ORDER BY userName. Params = array ( 'userId' => 1, ).
The dates that were entered - fromDt: 10/01/2015 00:00:00 and toDt: 11/05/2015 00:00:00
I have to apologize. I had forgotten that during some testing we disabled part of our code that would do the actual passing of the dates in ISO format. We re-enabled that part of our code, and the dates do get passed to the form_params correctly. But still the returned response was an empty array and the log shows that the API did not get the dates. So we then tried with the suggested changes to the fromDt and toDt using the Class. But all that did was tell me that the Date class was invalid. So we reverted the change and this is what we see in the log now.
12 66b0d50 2015-11-06 14:45 API GET DEBUG /stats SQL = SELECT stat.type, display.Display, layout.Layout, IFNULL(widgetoption.value, CONCAT(widget.type, '-', widget.widgetId)) AS Name, COUNT(StatID) AS NumberPlays, SUM(TIME_TO_SEC(TIMEDIFF(end, start))) AS Duration, MIN(start) AS MinStart, MAX(end) AS MaxEnd FROM stat INNER JOIN display ON stat.DisplayID = display.DisplayID INNER JOIN layout ON layout.LayoutID = stat.LayoutID LEFT OUTER JOIN `widget` ON `widget`.widgetId = stat.MediaID LEFT OUTER JOIN `widgetoption` ON `widgetoption`.widgetId = `widget`.widgetId AND `widgetoption`.type = 'attrib' AND `widgetoption`.option = 'name' WHERE stat.type <> 'displaydown' AND stat.end > :fromDt AND stat.start <= :toDt AND stat.displayID IN (2,1) GROUP BY stat.type, display.Display, layout.Layout, CONCAT(widget.type, '-', widget.widgetId) ORDER BY stat.type, display.Display, layout.Layout, Name . Params = array ( 'fromDt' => Jenssegers\Date\Date::__set_state(array( 'date' => '2015-11-05 14:45:06', 'timezone_type' => 3, 'timezone' => 'America/Los_Angeles', )), 'toDt' => Jenssegers\Date\Date::__set_state(array( 'date' => '2015-11-06 14:45:06', 'timezone_type' => 3, 'timezone' => 'America/Los_Angeles', )), ).
11 66b0d50 2015-11-06 14:45 API GET DEBUG /stats SQL = 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 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. Params = array ( ).
10 66b0d50 2015-11-06 14:45 API GET DEBUG /stats Converted Times received are: FromDt=2015-11-05 14:45:06. ToDt=2015-11-06 14:45:06
9 66b0d50 2015-11-06 14:45 API GET DEBUG /stats SQL = SELECT `group`.group, `group`.groupId, `group`.isUserSpecific, `group`.isEveryone, `group`.libraryQuota FROM `group` WHERE 1 = 1 AND `group`.groupId IN (SELECT groupId FROM `lkusergroup` WHERE userId = :userId) AND isUserSpecific = :isUserSpecific AND isEveryone = :isEveryone . Params = array ( 'userId' => 1, 'isUserSpecific' => 0, 'isEveryone' => 0, ).
8 66b0d50 2015-11-06 14:45 API GET DEBUG /stats Loading 1. All Objects = 0
7 66b0d50 2015-11-06 14:45 API GET DEBUG /stats SQL = SELECT `user`.userId, userName, userTypeId, loggedIn, email, `user`.homePageId, pages.title AS homePage, lastAccessed, newUserWizard, retired, CSPRNG, UserPassword AS password, group.groupId, group.group, 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 = :userId ORDER BY userName. Params = array ( 'userId' => 1, ).
So I think I will focus on trying to figure out why the API does not seem to be seeing the dates being passed.
Also just to note, on the code to get the date stats fixed. Can’t remember if the date selection in the CMS within the Alpha and Dev versions of the CMS were working, but they surely do now. However we don’t see any media in the date selections of the CMS:
UPDATE: I no more than got done typing this, and things changed. We decided to reboot everything. The server and the two test units.10 minutes later, we have stats from the api. Although not complete, and still the dates are not being passed. And also the results are not what we are expecting, As I outlined above it doesn’t look like the stats return media. However, I am thinking where “text-1”, and “text-2” are showing, this is actually the two media items we have scheduled on the layout, it is just that the names are not right. We will make a few changes to the schedule and compare the results.
Update 2: Media change on the layout did not change the stats at all. So Text-1 and Text-2 must be unrelated. Or maybe related to this:
Update 3: With the layout problem fixed and updating the client to R57, we now have the correct names on media in the Statistics page. (We also found out that currently you cannot register a R56 device on a 1.8 Dev) All form_params are still non-functional for us; tried the latest Dev code too. (Had to bypass react/qzm, It would not install.)
We thought the names were correct on the statics, turns out they are not, both in the CMS and with API. We see names like this: image-13, image-14, image-15.
On a different note, we are still unable to get dates or anything else passed correctly for stats. We applied the same code logic and formatting that worked on adding media to a region and creating the widgets, but no luck.
Yes, this is unfortunately true - there was an unfixable issue with the way the Android player selected which version of the XMDS schema it used to communicate. We quietly fixed it in R57 hoping more people would have this version by the time it all got released.
As for the media name not being shown, i’ve submitted a bug for it:
I’ve been round and round on the dates - no matter what I do I always get the dates I pass in to match the dates logged by the line: Converted Times received are: FromDt=2015-11-01 14:40:00. ToDt=2015-11-13 08:13:08.
May I suggest you add a log statement to see what’s in $_GET?