| 3013 |
vikas |
1 |
<%@page import="java.util.Map"%>
|
|
|
2 |
<%@page import="java.util.HashMap"%>
|
|
|
3 |
<%@page import="java.util.Calendar"%>
|
|
|
4 |
<%@page import="java.util.Date"%>
|
|
|
5 |
<%@page import="java.util.TimeZone"%>
|
|
|
6 |
<%@page import="java.text.SimpleDateFormat"%>
|
|
|
7 |
<%@page import="com.google.appengine.api.datastore.Query.SortDirection"%>
|
|
|
8 |
<%@page import="java.util.Map.Entry"%>
|
|
|
9 |
<%@ page import="java.util.List" %>
|
|
|
10 |
<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory" %>
|
|
|
11 |
<%@ page import="com.google.appengine.api.datastore.DatastoreService" %>
|
|
|
12 |
<%@ page import="com.google.appengine.api.datastore.Query" %>
|
|
|
13 |
<%@ page import="com.google.appengine.api.datastore.Entity" %>
|
|
|
14 |
<%@ page import="com.google.appengine.api.datastore.PreparedQuery" %>
|
|
|
15 |
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
|
|
16 |
|
|
|
17 |
<html>
|
|
|
18 |
<head>
|
|
|
19 |
<link rel="stylesheet" href="/DataTables/media/css/demo_table.css" type="text/css" />
|
|
|
20 |
<link rel="stylesheet" href="/DataTables/extras/TableTools/media/css/TableTools.css" type="text/css" />
|
|
|
21 |
</head>
|
|
|
22 |
<body>
|
|
|
23 |
<%
|
|
|
24 |
SimpleDateFormat iSdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
25 |
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("IST"));
|
|
|
26 |
String dateStr = request.getParameter("date");
|
|
|
27 |
if (dateStr != null && !dateStr.isEmpty()) {
|
|
|
28 |
cal.setTime(iSdf.parse(dateStr));
|
|
|
29 |
}
|
|
|
30 |
else {
|
|
|
31 |
dateStr = iSdf.format(cal.getTime());
|
|
|
32 |
}
|
|
|
33 |
cal.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
34 |
Date toDate = iSdf.parse(iSdf.format(cal.getTime()));
|
|
|
35 |
cal.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
36 |
Date fromDate = iSdf.parse(iSdf.format(cal.getTime()));
|
|
|
37 |
|
|
|
38 |
String fromDateStr = request.getParameter("fromDate");
|
|
|
39 |
if (fromDateStr == null || fromDateStr.isEmpty()) {
|
|
|
40 |
fromDateStr = iSdf.format(fromDate);
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
44 |
sdf.setTimeZone(TimeZone.getTimeZone("IST"));
|
|
|
45 |
DatastoreService datastore = DatastoreServiceFactory
|
|
|
46 |
.getDatastoreService();
|
|
|
47 |
Query query = new Query("DataLog");
|
|
|
48 |
query.addFilter("eventType", Query.FilterOperator.EQUAL, "PRODUCT_VIEW");
|
|
|
49 |
query.addFilter("date", Query.FilterOperator.GREATER_THAN_OR_EQUAL, fromDate);
|
|
|
50 |
query.addFilter("date", Query.FilterOperator.LESS_THAN, toDate);
|
|
|
51 |
PreparedQuery pq = datastore.prepare(query);
|
|
|
52 |
Map<String, Long> prodViewCountMap = new HashMap<String, Long>();
|
|
|
53 |
for (Entity result : pq.asIterable()) {
|
|
|
54 |
if (prodViewCountMap.containsKey((String)result.getProperty("productName"))) {
|
|
|
55 |
Long count = prodViewCountMap.get((String)result.getProperty("productName"));
|
|
|
56 |
prodViewCountMap.put((String)result.getProperty("productName"), ++count);
|
|
|
57 |
}
|
|
|
58 |
else {
|
|
|
59 |
prodViewCountMap.put((String)result.getProperty("productName"), 1L);
|
|
|
60 |
}
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
query = new Query("DataLog");
|
|
|
64 |
query.addFilter("eventType", Query.FilterOperator.EQUAL, "ADD_TO_CART");
|
|
|
65 |
query.addFilter("date", Query.FilterOperator.GREATER_THAN_OR_EQUAL, fromDate);
|
|
|
66 |
query.addFilter("date", Query.FilterOperator.LESS_THAN, toDate);
|
|
|
67 |
pq = datastore.prepare(query);
|
|
|
68 |
Map<Long, Long> prodAddToCartCountMap = new HashMap<Long, Long>();
|
|
|
69 |
for (Entity result : pq.asIterable()) {
|
|
|
70 |
for (Long itemId : (List<Long>)result.getProperty("itemIds")) {
|
|
|
71 |
if (prodAddToCartCountMap.containsKey(itemId)) {
|
|
|
72 |
Long count = prodAddToCartCountMap.get(itemId);
|
|
|
73 |
prodAddToCartCountMap.put(itemId, ++count);
|
|
|
74 |
}
|
|
|
75 |
else {
|
|
|
76 |
prodAddToCartCountMap.put(itemId, 1L);
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
query = new Query("DataLog");
|
|
|
82 |
query.addFilter("eventType", Query.FilterOperator.EQUAL, "DELETE_FROM_CART");
|
|
|
83 |
query.addFilter("date", Query.FilterOperator.GREATER_THAN_OR_EQUAL, fromDate);
|
|
|
84 |
query.addFilter("date", Query.FilterOperator.LESS_THAN, toDate);
|
|
|
85 |
pq = datastore.prepare(query);
|
|
|
86 |
Map<Long, Long> prodDeleteFromCartCountMap = new HashMap<Long, Long>();
|
|
|
87 |
for (Entity result : pq.asIterable()) {
|
|
|
88 |
for (Long itemId : (List<Long>)result.getProperty("itemIds")) {
|
|
|
89 |
if (prodDeleteFromCartCountMap.containsKey(itemId)) {
|
|
|
90 |
Long count = prodDeleteFromCartCountMap.get(itemId);
|
|
|
91 |
prodDeleteFromCartCountMap.put(itemId, ++count);
|
|
|
92 |
}
|
|
|
93 |
else {
|
|
|
94 |
prodDeleteFromCartCountMap.put(itemId, 1L);
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
query = new Query("DataLog");
|
|
|
100 |
query.addFilter("eventType", Query.FilterOperator.EQUAL, "RESEARCH_ADD");
|
|
|
101 |
query.addFilter("date", Query.FilterOperator.GREATER_THAN_OR_EQUAL, fromDate);
|
|
|
102 |
query.addFilter("date", Query.FilterOperator.LESS_THAN, toDate);
|
|
|
103 |
pq = datastore.prepare(query);
|
|
|
104 |
Map<Long, Long> prodResearchAddCountMap = new HashMap<Long, Long>();
|
|
|
105 |
for (Entity result : pq.asIterable()) {
|
|
|
106 |
for (Long itemId : (List<Long>)result.getProperty("itemIds")) {
|
|
|
107 |
if (prodResearchAddCountMap.containsKey(itemId)) {
|
|
|
108 |
Long count = prodResearchAddCountMap.get(itemId);
|
|
|
109 |
prodResearchAddCountMap.put(itemId, ++count);
|
|
|
110 |
}
|
|
|
111 |
else {
|
|
|
112 |
prodResearchAddCountMap.put(itemId, 1l);
|
|
|
113 |
}
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
query = new Query("DataLog");
|
|
|
118 |
query.addFilter("eventType", Query.FilterOperator.EQUAL, "RESEARCH_DELETE");
|
|
|
119 |
query.addFilter("date", Query.FilterOperator.GREATER_THAN_OR_EQUAL, fromDate);
|
|
|
120 |
query.addFilter("date", Query.FilterOperator.LESS_THAN, toDate);
|
|
|
121 |
pq = datastore.prepare(query);
|
|
|
122 |
Map<Long, Long> prodResearchDeleteCountMap = new HashMap<Long, Long>();
|
|
|
123 |
for (Entity result : pq.asIterable()) {
|
|
|
124 |
for (Long itemId : (List<Long>)result.getProperty("itemIds")) {
|
|
|
125 |
if (prodResearchDeleteCountMap.containsKey(itemId)) {
|
|
|
126 |
Long count = prodResearchDeleteCountMap.get(itemId);
|
|
|
127 |
prodResearchDeleteCountMap.put(itemId, ++count);
|
|
|
128 |
}
|
|
|
129 |
else {
|
|
|
130 |
prodResearchDeleteCountMap.put(itemId, 1L);
|
|
|
131 |
}
|
|
|
132 |
}
|
|
|
133 |
}
|
|
|
134 |
%>
|
|
|
135 |
<form id="frmProductActivity" name="frmProductActivity" method="post" action="/jsp/product-activity.jsp">
|
|
|
136 |
<label>Date(YYYYMMDD) : </label> <input type="text" name="date" id="date" value="<%= dateStr %>"/>
|
|
|
137 |
<input type="submit" name="submit" id="submit" value="Submit"/><br/>
|
|
|
138 |
</form>
|
|
|
139 |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="parent">
|
|
|
140 |
<tr>
|
|
|
141 |
<td colspan="2">
|
|
|
142 |
<table cellpadding="0" cellspacing="0" border="0" class="display"
|
|
|
143 |
id="prodView">
|
|
|
144 |
<thead>
|
|
|
145 |
<tr>
|
|
|
146 |
<th>Product</th>
|
|
|
147 |
<th>ViewCount</th>
|
|
|
148 |
</tr>
|
|
|
149 |
</thead>
|
|
|
150 |
<tbody>
|
|
|
151 |
|
|
|
152 |
<%
|
|
|
153 |
for (Entry entry : prodViewCountMap.entrySet()) {
|
|
|
154 |
%>
|
|
|
155 |
<tr>
|
|
|
156 |
<td><%= entry.getKey()%></td>
|
|
|
157 |
<td><%=entry.getValue()%></td>
|
|
|
158 |
</tr>
|
|
|
159 |
<%
|
|
|
160 |
}
|
|
|
161 |
%>
|
|
|
162 |
</tbody>
|
|
|
163 |
</table>
|
|
|
164 |
</td>
|
|
|
165 |
<td>
|
|
|
166 |
<table cellpadding="0" cellspacing="0" border="0" class="display"
|
|
|
167 |
id="prodCartAdd">
|
|
|
168 |
<thead>
|
|
|
169 |
<tr>
|
|
|
170 |
<th>Product</th>
|
|
|
171 |
<th>Cart Add</th>
|
|
|
172 |
</tr>
|
|
|
173 |
</thead>
|
|
|
174 |
<tbody>
|
|
|
175 |
|
|
|
176 |
<%
|
|
|
177 |
for (Entry entry : prodAddToCartCountMap.entrySet()) {
|
|
|
178 |
%>
|
|
|
179 |
<tr>
|
|
|
180 |
<td><%= entry.getKey()%></td>
|
|
|
181 |
<td><%=entry.getValue()%></td>
|
|
|
182 |
</tr>
|
|
|
183 |
<%
|
|
|
184 |
}
|
|
|
185 |
%>
|
|
|
186 |
</tbody>
|
|
|
187 |
</table>
|
|
|
188 |
</td>
|
|
|
189 |
</tr>
|
|
|
190 |
<tr>
|
|
|
191 |
<td>
|
|
|
192 |
<table cellpadding="0" cellspacing="0" border="0" class="display"
|
|
|
193 |
id="prodDeletedFromCart">
|
|
|
194 |
<thead>
|
|
|
195 |
<tr>
|
|
|
196 |
<th>Product</th>
|
|
|
197 |
<th>Cart Delete</th>
|
|
|
198 |
</tr>
|
|
|
199 |
</thead>
|
|
|
200 |
<tbody>
|
|
|
201 |
|
|
|
202 |
<%
|
|
|
203 |
for (Entry entry : prodDeleteFromCartCountMap.entrySet()) {
|
|
|
204 |
%>
|
|
|
205 |
<tr>
|
|
|
206 |
<td><%= entry.getKey()%></td>
|
|
|
207 |
<td><%=entry.getValue()%></td>
|
|
|
208 |
</tr>
|
|
|
209 |
<%
|
|
|
210 |
}
|
|
|
211 |
%>
|
|
|
212 |
</tbody>
|
|
|
213 |
</table>
|
|
|
214 |
</td>
|
|
|
215 |
<td>
|
|
|
216 |
<table cellpadding="0" cellspacing="0" border="0" class="display"
|
|
|
217 |
id="prodResearchAdd">
|
|
|
218 |
<thead>
|
|
|
219 |
<tr>
|
|
|
220 |
<th>Product</th>
|
|
|
221 |
<th>Research Add</th>
|
|
|
222 |
</tr>
|
|
|
223 |
</thead>
|
|
|
224 |
<tbody>
|
|
|
225 |
|
|
|
226 |
<%
|
|
|
227 |
for (Entry entry : prodResearchAddCountMap.entrySet()) {
|
|
|
228 |
%>
|
|
|
229 |
<tr>
|
|
|
230 |
<td><%= entry.getKey()%></td>
|
|
|
231 |
<td><%=entry.getValue()%></td>
|
|
|
232 |
</tr>
|
|
|
233 |
<%
|
|
|
234 |
}
|
|
|
235 |
%>
|
|
|
236 |
</tbody>
|
|
|
237 |
</table>
|
|
|
238 |
</td>
|
|
|
239 |
<td>
|
|
|
240 |
<table cellpadding="0" cellspacing="0" border="0" class="display"
|
|
|
241 |
id="prodResearchDelete">
|
|
|
242 |
<thead>
|
|
|
243 |
<tr>
|
|
|
244 |
<th>Product</th>
|
|
|
245 |
<th>Research Delete</th>
|
|
|
246 |
</tr>
|
|
|
247 |
</thead>
|
|
|
248 |
<tbody>
|
|
|
249 |
|
|
|
250 |
<%
|
|
|
251 |
for (Entry entry : prodResearchDeleteCountMap.entrySet()) {
|
|
|
252 |
%>
|
|
|
253 |
<tr>
|
|
|
254 |
<td><%= entry.getKey()%></td>
|
|
|
255 |
<td><%=entry.getValue()%></td>
|
|
|
256 |
</tr>
|
|
|
257 |
<%
|
|
|
258 |
}
|
|
|
259 |
%>
|
|
|
260 |
</tbody>
|
|
|
261 |
</table>
|
|
|
262 |
</td>
|
|
|
263 |
</tr>
|
|
|
264 |
</table>
|
|
|
265 |
|
|
|
266 |
<script type="text/javascript" language="javascript" src="/DataTables/media/js/jquery.js"></script>
|
|
|
267 |
<script type="text/javascript" language="javascript" src="/DataTables/media/js/jquery.dataTables.min.js"></script>
|
|
|
268 |
<script type="text/javascript" charset="utf-8" src="/DataTables/extras/TableTools/media/js/ZeroClipboard.js"></script>
|
|
|
269 |
<script type="text/javascript" charset="utf-8" src="/DataTables/extras/TableTools/media/js/TableTools.js"></script>
|
|
|
270 |
<script type="text/javascript" charset="utf-8">
|
|
|
271 |
$(document).ready(function() {
|
|
|
272 |
$('#prodView').dataTable({
|
|
|
273 |
"iDisplayLength": 10,
|
|
|
274 |
"bProcessing": true,
|
|
|
275 |
"aaSorting": [[1,'desc']],
|
|
|
276 |
"aLengthMenu": [[5, 10, 25,-1], [5, 10, 25, "All"]]
|
|
|
277 |
});
|
|
|
278 |
} );
|
|
|
279 |
$(document).ready(function() {
|
|
|
280 |
$('#prodCartAdd').dataTable({
|
|
|
281 |
"iDisplayLength": 10,
|
|
|
282 |
"bProcessing": true,
|
|
|
283 |
"aaSorting": [[1,'desc']],
|
|
|
284 |
"aLengthMenu": [[5, 10, 25,-1], [5, 10, 25, "All"]]
|
|
|
285 |
});
|
|
|
286 |
} );
|
|
|
287 |
$(document).ready(function() {
|
|
|
288 |
$('#prodDeletedFromCart').dataTable({
|
|
|
289 |
"iDisplayLength": 10,
|
|
|
290 |
"bProcessing": true,
|
|
|
291 |
"aaSorting": [[1,'desc']],
|
|
|
292 |
"aLengthMenu": [[5, 10, 25,-1], [5, 10, 25, "All"]]
|
|
|
293 |
});
|
|
|
294 |
} );
|
|
|
295 |
$(document).ready(function() {
|
|
|
296 |
$('#prodResearchAdd').dataTable({
|
|
|
297 |
"iDisplayLength": 10,
|
|
|
298 |
"bProcessing": true,
|
|
|
299 |
"aaSorting": [[1,'desc']],
|
|
|
300 |
"aLengthMenu": [[5, 10, 25,-1], [5, 10, 25, "All"]]
|
|
|
301 |
});
|
|
|
302 |
} );
|
|
|
303 |
$(document).ready(function() {
|
|
|
304 |
$('#prodResearchDelete').dataTable({
|
|
|
305 |
"iDisplayLength": 10,
|
|
|
306 |
"bProcessing": true,
|
|
|
307 |
"aaSorting": [[1,'desc']],
|
|
|
308 |
"aLengthMenu": [[5, 10, 25,-1], [5, 10, 25, "All"]]
|
|
|
309 |
});
|
|
|
310 |
} );
|
|
|
311 |
</script>
|
|
|
312 |
</body>
|
|
|
313 |
</html>
|