Now we are going to see how live data can be requested from the one-minute-server and analyzed.
Get this thing started
Here you see the default view with no data available. To request data from the server you have to push the start-button. Press it now. It makes sense to have differnt times, because request time should not be over 60 seconds, but display time you can have 2 minutes, if its ok for your application. In the config-view you can set the sever (here my demo-appliance) and how often the data should be requested and the data sould be updated in the view. In the demo-panel you can choose different things
There are differnt labels a user can go to in this demo-shop
{"category" : "Startseite/Elektronik & Computer/Unterhaltungselektronik/TV, Audio & Video/Fernseher & ZubehörFernseher", "content" : "Telefunken Full HD LED TV 102cm"},
....
Type of shopper : … a person visiting random pages from the list … a person visiting the pages in the the natural order … 10 persons visiting random pages … 100 persons visiting random pages
Pause between request 1/8 second, 1/4 second,.. till random 5-20 Seconds
How much requests are send (5,10,..10000 )
and a request down-counter
You have got to press start to send requests. Press it now.
A few moments later, denpending on your settings, you see this:
It you let this run for a while, you will see the requests disapear from the last minute. On the right side you see the top 5 content requests since the app loaded. They will not dissapear after a minute. They stay till you close the browser, or hit F5.
The Code in analytics.js
After hitting the start-button, the function “start” is called
In this function the data are splitted into lines and parsed. Neccessary values like time-values are added. If there are new columns, they are added to the database. Database will be created if it doesnt exist. The column names are dynamic and must be the same on the sending client and the sql here.
I choosed a simple design (6 displays per page, 2 in a line. id of every element: 1 to 6) For every analyze you have got a sql, a display type and some html/css-properties Get all entries for the current page; execute the sql, put the values in a converter, display it on the right id, ready !
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
functiondisplayData(){
//console.log("display");
var analyseLayout=[
{ "title" : "Last 5 Content from last minute",
"page" : 1,
"into" :"1",
"sql" : "Select top 5 content, datum from rawdata where trackingtime > "+ (newDate().getTime()-60000) + " order by 2 desc",
"display" : "simpletable",
"heading" : ['Inhalt','Zeit'],
"dclass" : ".col-md-4"
},
{ "title" : "Top 5 Content ",
"page" : 1,
"into" : "2",
"sql" : "Select top 5 content, count(*) from rawdata group by content order by 2 desc",
"display" : "simpletable",
"heading" : ['Kampange','Anzahl'],
"dclass" : ".col-md-4"
},
{ "title" : "Anzahl User",
"page" : 1,
"into" : "3",
"sql" : "select count(*) from (Select distinct user from rawdata )",
"display" : "simpletable",
"heading" : ['Benutzer'],
"dclass" : ".col-md-4"
}
];
for(var n = 1;n <= 6; n++ ) {
$("#loc"+ n ).html("<h3><a href='#'></a></h3>");
}
for(index in analyseLayout){
var ana = analyseLayout[index];
if(ana.page==dataworld.currentpage){
var localresult="<h3><a href='#'>" +ana.title+ "</a></h3>";