| 4638 |
amar.kumar |
1 |
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
|
|
2 |
pageEncoding="UTF-8"%>
|
|
|
3 |
<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory" %>
|
|
|
4 |
<%@ page import="com.google.appengine.api.datastore.DatastoreService" %>
|
|
|
5 |
<%@ page import="com.google.appengine.api.datastore.Query" %>
|
|
|
6 |
<%@ page import="com.google.appengine.api.datastore.Entity" %>
|
|
|
7 |
<%@ page import="com.google.appengine.api.datastore.PreparedQuery" %>
|
|
|
8 |
<%@ page import="com.google.appengine.api.datastore.Query.SortDirection"%>
|
|
|
9 |
<%@ page import="java.util.Calendar"%>
|
|
|
10 |
<%@ page import="java.util.Map"%>
|
| 4816 |
amar.kumar |
11 |
<%@ page import="java.util.LinkedHashMap"%>
|
| 4638 |
amar.kumar |
12 |
<%@ page import="java.util.Map.Entry"%>
|
|
|
13 |
<%@ page import="java.text.ParseException"%>
|
|
|
14 |
<%@ page import="java.util.TimeZone"%>
|
|
|
15 |
<%@ page import="java.util.Date"%>
|
| 4816 |
amar.kumar |
16 |
<%@ page import="java.util.Set"%>
|
|
|
17 |
<%@ page import="java.util.Calendar"%>
|
| 4638 |
amar.kumar |
18 |
<%@ page import="java.text.SimpleDateFormat"%>
|
|
|
19 |
<%@ page import="in.shop2020.model.Category"%>
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
<html>
|
|
|
23 |
<head>
|
| 4816 |
amar.kumar |
24 |
|
|
|
25 |
<script>
|
|
|
26 |
var dataArray = [];
|
|
|
27 |
</script>
|
|
|
28 |
<script type="text/javascript" language="javascript" src="/DataTables/media/js/jquery.js"></script>
|
|
|
29 |
<script type="text/javascript" language="javascript" src="/DataTables/media/js/jquery.dataTables.min.js"></script>
|
|
|
30 |
<script type="text/javascript" charset="utf-8" src="/DataTables/extras/TableTools/media/js/ZeroClipboard.js"></script>
|
|
|
31 |
<script type="text/javascript" charset="utf-8" src="/DataTables/extras/TableTools/media/js/TableTools.js"></script>
|
|
|
32 |
<script src="/js/flot/jquery.flot.js" ></script>
|
|
|
33 |
<script type="text/javascript" src = "/js/flot/jquery.flot.navigate.js"></script>
|
|
|
34 |
|
| 4638 |
amar.kumar |
35 |
<link rel="stylesheet" href="/DataTables/media/css/demo_table.css" type="text/css" />
|
|
|
36 |
<link rel="stylesheet" href="/DataTables/extras/TableTools/media/css/TableTools.css" type="text/css" />
|
|
|
37 |
<title>Search Analysis</title>
|
|
|
38 |
</head>
|
|
|
39 |
<body>
|
|
|
40 |
<%
|
|
|
41 |
Date toDate = new Date();
|
|
|
42 |
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("IST"));
|
|
|
43 |
cal.add(Calendar.DAY_OF_MONTH, -2);
|
|
|
44 |
Date fromDate = cal.getTime();
|
|
|
45 |
SimpleDateFormat iSdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
46 |
String toDateStr = request.getParameter("toDate");
|
|
|
47 |
String fromDateStr = request.getParameter("fromDate");
|
|
|
48 |
if (fromDateStr == null || fromDateStr.isEmpty()) {
|
|
|
49 |
fromDateStr = iSdf.format(fromDate);
|
|
|
50 |
}
|
|
|
51 |
if (toDateStr == null || toDateStr.isEmpty()) {
|
|
|
52 |
toDateStr = iSdf.format(toDate);
|
|
|
53 |
}
|
|
|
54 |
String eventType = "PRODUCT_SEARCH";
|
|
|
55 |
String productQuery = request.getParameter("productQuery");
|
|
|
56 |
%>
|
|
|
57 |
|
|
|
58 |
<form id="searchfilter" name="searchfilter" method="post" action="/jsp/productSearch.jsp">
|
|
|
59 |
<label>From Date(YYYYMMDD) : </label> <input type="text" name="fromDate" id="fromDate" value="<%= fromDateStr %>"/>
|
|
|
60 |
<label>To Date(YYYYMMDD) : </label> <input type="text" name="toDate" id="toDate" value="<%= toDateStr %>"/>
|
| 4932 |
amar.kumar |
61 |
<% if(productQuery!=null){
|
|
|
62 |
%>
|
|
|
63 |
<input type="text" name="productQuery" style = "display:none "value="<%= productQuery %>"/>
|
|
|
64 |
<% } %>
|
| 4638 |
amar.kumar |
65 |
<input type="Submit" id="Submit" name="Submit" value="Submit" />
|
|
|
66 |
</form>
|
|
|
67 |
|
|
|
68 |
<%
|
|
|
69 |
try {
|
|
|
70 |
if (fromDateStr != null) {
|
|
|
71 |
fromDate = iSdf.parse(fromDateStr);
|
|
|
72 |
}
|
|
|
73 |
if (toDateStr != null) {
|
|
|
74 |
toDate = iSdf.parse(toDateStr);
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
catch (ParseException pe) {
|
|
|
78 |
%>
|
|
|
79 |
<span>Invalid Date Format</span>
|
|
|
80 |
<%
|
|
|
81 |
}
|
|
|
82 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
83 |
sdf.setTimeZone(TimeZone.getTimeZone("IST"));
|
| 4816 |
amar.kumar |
84 |
|
|
|
85 |
//Initializing Date variables for calculation of graph data
|
|
|
86 |
Map<Long, Long> graphData = new LinkedHashMap<Long, Long>();
|
|
|
87 |
long previousDate = fromDate.getTime();
|
|
|
88 |
graphData.put(previousDate, new Long(0));
|
|
|
89 |
Calendar currentRecordDate = Calendar.getInstance();
|
|
|
90 |
currentRecordDate.setTimeInMillis(fromDate.getTime());
|
|
|
91 |
Calendar previousrecordDate = Calendar.getInstance();
|
|
|
92 |
previousrecordDate.setTimeInMillis(fromDate.getTime());
|
|
|
93 |
|
| 4638 |
amar.kumar |
94 |
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
|
|
|
95 |
Query query = new Query("DataLog");
|
|
|
96 |
query.addFilter("eventType", Query.FilterOperator.EQUAL, "PRODUCT_SEARCH");
|
|
|
97 |
query.addFilter("date", Query.FilterOperator.GREATER_THAN_OR_EQUAL, fromDate);
|
|
|
98 |
query.addFilter("date", Query.FilterOperator.LESS_THAN_OR_EQUAL, toDate);
|
|
|
99 |
if(productQuery!=null){
|
|
|
100 |
query.addFilter("query",Query.FilterOperator.EQUAL,productQuery);
|
|
|
101 |
}
|
|
|
102 |
PreparedQuery pq = datastore.prepare(query);
|
|
|
103 |
%>
|
|
|
104 |
|
|
|
105 |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="searchData">
|
|
|
106 |
<thead>
|
|
|
107 |
<tr>
|
|
|
108 |
<th>Date</th>
|
|
|
109 |
<th>UserId</th>
|
|
|
110 |
<th>Session</th>
|
|
|
111 |
<th>Query String</th>
|
|
|
112 |
<th>Category</th>
|
|
|
113 |
<th>Number of Results</th>
|
|
|
114 |
</tr>
|
|
|
115 |
</thead>
|
|
|
116 |
<tbody>
|
|
|
117 |
<%
|
|
|
118 |
for (Entity result : pq.asIterable()) {
|
| 4816 |
amar.kumar |
119 |
|
|
|
120 |
currentRecordDate.setTime((Date)(result.getProperty("date")));
|
|
|
121 |
|
|
|
122 |
if((currentRecordDate.getTimeInMillis() - previousDate) >= 86400000) {
|
|
|
123 |
|
|
|
124 |
long dayDiff = (currentRecordDate.getTimeInMillis() - previousrecordDate.getTimeInMillis()) / 86400000;
|
|
|
125 |
|
|
|
126 |
for(int i = 1; i <= dayDiff; i ++) {
|
|
|
127 |
previousDate = previousDate + 86400000;
|
|
|
128 |
previousrecordDate.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
129 |
graphData.put(previousDate, new Long(0));
|
|
|
130 |
}
|
|
|
131 |
graphData.put(previousDate, graphData.get(previousDate) + 1);
|
|
|
132 |
}
|
| 4638 |
amar.kumar |
133 |
%>
|
|
|
134 |
<tr>
|
|
|
135 |
<td><%=sdf.format((Date) (result.getProperty("date")))%></td>
|
|
|
136 |
<td><a href="/jsp/user-activity.jsp?email=<%=result.getProperty("email").toString()%>"><%= result.getProperty("email").toString() %></a></td>
|
|
|
137 |
<td><a href="/jsp/session-activity.jsp?sessionId=<%=result.getProperty("sessionId").toString()%>">View Session</a></td>
|
|
|
138 |
<td><%=(result.getProperty("query")) %></td>
|
|
|
139 |
<td><%=Category.findByValue(Integer.parseInt(result.getProperty("categoryId").toString())) %></td>
|
|
|
140 |
<td><%=(result.getProperty("totalResults")) %></td>
|
|
|
141 |
</tr>
|
|
|
142 |
<%}%>
|
|
|
143 |
|
|
|
144 |
</tbody>
|
|
|
145 |
</table>
|
| 4816 |
amar.kumar |
146 |
<br/>
|
|
|
147 |
<br/>
|
|
|
148 |
<br/>
|
|
|
149 |
<div id = "zoombuttonholder"></div>
|
| 4638 |
amar.kumar |
150 |
|
| 4816 |
amar.kumar |
151 |
<%Set<Long> dateSet = graphData.keySet();
|
|
|
152 |
for(Long date : dateSet){%>
|
|
|
153 |
<script>
|
|
|
154 |
//Putting Graph data in javascript array
|
|
|
155 |
dataArray.push([<%=date%>,<%=graphData.get(date)%>]);
|
|
|
156 |
</script>
|
|
|
157 |
<%} %>
|
|
|
158 |
<div id="placeholder" style="position:relative;width:950px;height:300px"></div>
|
|
|
159 |
<br>
|
| 4638 |
amar.kumar |
160 |
|
| 4816 |
amar.kumar |
161 |
<h3><a href= "/jsp/productSearchFrequency.jsp?toDate=<%=toDateStr%>&fromDate=<%=fromDateStr%>">Go back to Product Search Frequencies</a></h3>
|
|
|
162 |
|
|
|
163 |
|
| 4638 |
amar.kumar |
164 |
<script type="text/javascript" charset="utf-8">
|
| 4816 |
amar.kumar |
165 |
|
| 4638 |
amar.kumar |
166 |
$(document).ready(function() {
|
|
|
167 |
$('#searchData').dataTable({
|
|
|
168 |
"sPaginationType": "full_numbers",
|
|
|
169 |
"bProcessing": true,
|
|
|
170 |
"bStateSave": true,
|
|
|
171 |
"sDom": 'T<"clear">lfrtip',
|
|
|
172 |
"bFilter": false,
|
|
|
173 |
"oTableTools": {
|
|
|
174 |
"sSwfPath": "/DataTables/extras/TableTools/media/swf/copy_cvs_xls_pdf.swf"
|
|
|
175 |
},
|
|
|
176 |
"aoColumns": [
|
|
|
177 |
null,
|
|
|
178 |
null,
|
|
|
179 |
null,
|
|
|
180 |
null,
|
|
|
181 |
null,
|
|
|
182 |
null
|
|
|
183 |
]
|
|
|
184 |
});
|
| 4816 |
amar.kumar |
185 |
var options = {
|
|
|
186 |
legend: {
|
|
|
187 |
show: true,
|
|
|
188 |
margin: 10,
|
|
|
189 |
backgroundOpacity: 0.5
|
|
|
190 |
},
|
|
|
191 |
points: {
|
|
|
192 |
show: true,
|
|
|
193 |
},
|
|
|
194 |
lines: {
|
|
|
195 |
show: true,
|
|
|
196 |
lineWidth: 1,
|
|
|
197 |
fill: true,
|
|
|
198 |
fillColor: { colors: [ "#87CEFA",{ opacity: 0.05 } ] }
|
|
|
199 |
},
|
|
|
200 |
xaxis: {
|
|
|
201 |
mode:"time",
|
|
|
202 |
timeformat: "%y/%m/%d",
|
|
|
203 |
panRange: [<%=fromDate.getTime()%>,<%=toDate.getTime()%>]
|
|
|
204 |
},
|
|
|
205 |
yaxis: {
|
|
|
206 |
panRange: [0,5000]
|
|
|
207 |
},
|
|
|
208 |
fill: true,
|
|
|
209 |
zoom: {
|
|
|
210 |
interactive: true
|
|
|
211 |
},
|
|
|
212 |
pan: {
|
|
|
213 |
interactive: true
|
|
|
214 |
},
|
|
|
215 |
};
|
|
|
216 |
|
|
|
217 |
var data = [
|
|
|
218 |
{
|
|
|
219 |
label: "Product Search Frequency",
|
|
|
220 |
data: dataArray,
|
|
|
221 |
}
|
|
|
222 |
];
|
|
|
223 |
//Generating the graph with specified "data" & "options" in div "placeholder"
|
|
|
224 |
var plot = $.plot($("#placeholder"),data,options);
|
|
|
225 |
|
|
|
226 |
// add zoom out button
|
|
|
227 |
$('<div class="button" style="width:75px;color:#999;left:800px;cursor:pointer;background-color:#eee;padding:2px">zoom out</div>').appendTo($('#zoombuttonholder')).click(function (e) {
|
|
|
228 |
e.preventDefault();
|
|
|
229 |
plot.zoomOut();
|
|
|
230 |
});
|
| 4638 |
amar.kumar |
231 |
} );
|
|
|
232 |
</script>
|
|
|
233 |
</body>
|
|
|
234 |
</html>
|