From f4b974ea52f8c00fb9751aabc1d20b07a68e73a1 Mon Sep 17 00:00:00 2001 From: charithag Date: Fri, 7 Aug 2015 15:02:49 +0530 Subject: [PATCH] Add data simulation --- .../jaggeryapps/iotserver/api/event-api.jag | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/event-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/event-api.jag index 944722c1..5a052ed0 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/event-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/event-api.jag @@ -43,8 +43,23 @@ var data; var groupId; if (uriMatcher.match("/{context}/api/event/list")) { + /* + var timeInterval = 30; + var i, rnd; + result = []; + var currentDay = new Date(); + var startDate = currentDay.getTime() - (60 * 60 * 24 * 100); + var endDate = currentDay.getTime(); + + var i = parseInt(startDate / 1000); + while (i < parseInt(endDate / 1000)) { + rnd = rnd = Math.random() * 50; + result.push({time: i, deviceName: 'device' + rnd, activity:'Event number ' + rnd}); + i += timeInterval; + } + */ try { - fetchedData = statsClient.getRecentDeviceStats(user, 10); + result = statsClient.getRecentDeviceStats(user, 10); } catch (error) { log.error(error); }