The API that returns Statistics api/stats is retruning nothing though for the same date range, I get some stats from the CMS UI’s Statistics link.
curl -X GET -H “Authorization: token” -H “Cache-Control: no-cache” ‘http://MyXiboSvr/api/stats?fromDt=2015-12-04 00:00:00&toDt=2016-02-04 00:00:00’
I am not sure if the date format I am using in the curl above is wrong. I also noticed that the SQL query that is built in the grid() method of Stats.php has an error in the SQL syntax. The SQL looks like below in my case. I think the ‘option’ column of widgetoption
table being a reserved MySQL word, needs to be escaped by backticks as well.
I tried to change it locally in my CMS instance but still get no rows returned. Probably there something more I am missing.
SELECT stat.type, display.Display, layout.Layout, IFNULL(
media
.name, 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 JOINwidget
ONwidget
.widgetId = stat.MediaID LEFT OUTER JOINwidgetoption
ONwidgetoption
.widgetId =widget
.widgetId ANDwidgetoption
.type = ‘attrib’
ANDwidgetoption
.option = ‘name’ LEFT OUTER JOINlkwidgetmedia
ONlkwidgetmedia
.widgetId =widget
.widgetId LEFT OUTER JOINmedia
ONmedia
.mediaId =lkwidgetmedia
.mediaId ANDmedia
.type <> ‘module’ WHERE stat.type <> ‘displaydown’
AND stat.end > ‘2015-12-04 00:00:00’ AND stat.start <= ‘2016-02-04 00:00:00’ AND stat.displayID IN (151,152,153,150)
GROUP BY stat.type, display.Display, layout.Layout, CONCAT(widget.type, ‘-’, widget.widgetId) ORDER BY stat.type, display.Display, layout.Layout, Name
- Regards