| Line 42... |
Line 42... |
| 42 |
private static final String EVENTTYPE_FIELD = "eventType";
|
42 |
private static final String EVENTTYPE_FIELD = "eventType";
|
| 43 |
private static final String DATE_FIELD = "date";
|
43 |
private static final String DATE_FIELD = "date";
|
| 44 |
private static final String FIRST_SOURCE_FIELD = "firstSource";
|
44 |
private static final String FIRST_SOURCE_FIELD = "firstSource";
|
| 45 |
private static final String SESSION_SOURCE_FIELD = "source";
|
45 |
private static final String SESSION_SOURCE_FIELD = "source";
|
| 46 |
|
46 |
|
| 47 |
|
- |
|
| 48 |
private static final String PRODUCT_VIEW_EVENT = "PRODUCT_VIEW";
|
47 |
private static final String PRODUCT_VIEW_EVENT = "PRODUCT_VIEW";
|
| 49 |
private static final String ADD_TO_CART_EVENT = "ADD_TO_CART";
|
48 |
private static final String ADD_TO_CART_EVENT = "ADD_TO_CART";
|
| 50 |
private static final String DELETE_FROM_CART_EVENT = "DELETE_FROM_CART";
|
49 |
private static final String DELETE_FROM_CART_EVENT = "DELETE_FROM_CART";
|
| 51 |
private static final String RESEARCH_ADD_EVENT = "RESEARCH_ADD";
|
50 |
private static final String RESEARCH_ADD_EVENT = "RESEARCH_ADD";
|
| 52 |
private static final String RESEARCH_DELETE_EVENT = "RESEARCH_DELETE";
|
51 |
private static final String RESEARCH_DELETE_EVENT = "RESEARCH_DELETE";
|
| Line 88... |
Line 87... |
| 88 |
|
87 |
|
| 89 |
private Map<String, Map<String, String>> sessionIdSourceMap;
|
88 |
private Map<String, Map<String, String>> sessionIdSourceMap;
|
| 90 |
|
89 |
|
| 91 |
private Date fromDate;
|
90 |
private Date fromDate;
|
| 92 |
private Date toDate;
|
91 |
private Date toDate;
|
| - |
|
92 |
|
| - |
|
93 |
private Date queryFromDate;
|
| - |
|
94 |
private Date queryToDate;
|
| - |
|
95 |
|
| 93 |
private DatastoreService datastore;
|
96 |
private DatastoreService datastore;
|
| 94 |
|
97 |
|
| 95 |
public void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
98 |
public void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
| 96 |
logger.warning("Running DailyProductWithSourceAggregator");
|
99 |
logger.warning("Running DailyProductWithSourceAggregator");
|
| 97 |
sessionIdSourceMap = new HashMap<String, Map<String,String>>();
|
100 |
sessionIdSourceMap = new HashMap<String, Map<String,String>>();
|
| Line 126... |
Line 129... |
| 126 |
itemsMap.put(item.getId(), item);
|
129 |
itemsMap.put(item.getId(), item);
|
| 127 |
itemsCatalogIdMap.put(item.getCatalogId(), item);
|
130 |
itemsCatalogIdMap.put(item.getCatalogId(), item);
|
| 128 |
itemsNameMap.put(item.getName().trim(), item);
|
131 |
itemsNameMap.put(item.getName().trim(), item);
|
| 129 |
}
|
132 |
}
|
| 130 |
|
133 |
|
| 131 |
logger.warning("DailyProductWithSourceAggregator : Updating View Count Map");
|
- |
|
| 132 |
UpdateViewCount(PRODUCT_VIEW_EVENT, VIEW_COUNT_KEY, UNIQUE_VIEW_COUNT_KEY);
|
- |
|
| 133 |
logger.warning("DailyProductWithSourceAggregator : itemsResultMap size : " + itemsResultMap.size());
|
- |
|
| 134 |
logger.warning("DailyProductWithSourceAggregator : sessionIdSourceMap size : " + sessionIdSourceMap.size());
|
- |
|
| 135 |
|
- |
|
| 136 |
logger.warning("DailyProductWithSourceAggregator : Updating Add To Cart Count Map");
|
- |
|
| 137 |
UpdateItemIdEventCount(ADD_TO_CART_EVENT, ADD_TO_CART_COUNT_KEY, UNIQUE_ADD_TO_CART_COUNT_KEY, false);
|
- |
|
| 138 |
logger.warning("DailyProductWithSourceAggregator : Updating Delete From Cart Count Map");
|
- |
|
| 139 |
UpdateItemIdEventCount(DELETE_FROM_CART_EVENT, DELETE_FROM_CART_COUNT_KEY, UNIQUE_DELETE_FROM_CART_COUNT_KEY, false);
|
- |
|
| 140 |
logger.warning("DailyProductWithSourceAggregator : Updating Add To Research Count Map");
|
- |
|
| 141 |
UpdateItemIdEventCount(RESEARCH_ADD_EVENT, ADD_TO_RESEARCH_COUNT_KEY, UNIQUE_ADD_TO_RESEARCH_COUNT_KEY, true);
|
- |
|
| 142 |
logger.warning("DailyProductWithSourceAggregator : Updating Delete From Research Count Map");
|
- |
|
| 143 |
UpdateItemIdEventCount(RESEARCH_DELETE_EVENT, DELETE_FROM_RESEARCH_COUNT_KEY, UNIQUE_DELETE_FROM_RESEARCH_COUNT_KEY, true);
|
- |
|
| 144 |
|
- |
|
| 145 |
logger.warning("DailyProductWithSourceAggregator : Updating ShippingAccessCount Count Map");
|
- |
|
| 146 |
UpdateItemIdEventCount(SHIPPING_ACCESS_EVENT, SHIPPING_ACCESS_COUNT_KEY, UNIQUE_SHIPPING_ACCESS_COUNT_KEY, false);
|
- |
|
| 147 |
logger.warning("DailyProductWithSourceAggregator : Updating Payment Success Count Map");
|
- |
|
| 148 |
UpdateItemIdEventCount(PAYMENT_SUCCESS_EVENT, PAYMENT_SUCCESS_COUNT_KEY, UNIQUE_PAYMENT_SUCCESS_COUNT_KEY, false);
|
- |
|
| 149 |
logger.warning("DailyProductWithSourceAggregator : Updating Order Creation Count Map");
|
- |
|
| 150 |
UpdateItemIdEventCount(ORDER_CREATION_EVENT, ORDER_CREATION_COUNT_KEY, UNIQUE_ORDER_CREATION_COUNT_KEY, false);
|
- |
|
| 151 |
logger.warning("DailyProductWithSourceAggregator : Updating Payment Failure Count Map");
|
- |
|
| 152 |
UpdateItemIdEventCount(PAYMENT_FAILURE_EVENT, PAYMENT_FAILURE_COUNT_KEY, UNIQUE_PAYMENT_FAILURE_COUNT_KEY, false);
|
- |
|
| 153 |
logger.warning("DailyProductWithSourceAggregator : Updating Proceed To Pay Count Map");
|
- |
|
| 154 |
UpdateItemIdEventCount(PROCEED_TO_PAY_EVENT, PROCEED_TO_PAY_COUNT_KEY, UNIQUE_PROCEED_TO_PAY_COUNT_KEY, false);
|
- |
|
| 155 |
|
- |
|
| 156 |
List<ItemActivityWithSource> itemActivities = new ArrayList<ItemActivityWithSource>();
|
- |
|
| 157 |
ItemActivityWithSourceRepository itemActivityRepository = new ItemActivityWithSourceRepository();
|
- |
|
| 158 |
for (Entry<String, Map<String, Long>> entry : itemsResultMap.entrySet()) {
|
134 |
for (int i = 0; i < 4; i++) {
|
| 159 |
String key = (String)entry.getKey();
|
135 |
cal.setTime(fromDate);
|
| 160 |
Map<String, Long> itemMap = (Map<String, Long>)entry.getValue();
|
136 |
cal.add(Calendar.HOUR_OF_DAY, 6*i);
|
| 161 |
|
- |
|
| 162 |
String [] keyItems = key.split("_");
|
137 |
queryFromDate = cal.getTime();
|
| 163 |
|
138 |
|
| 164 |
Boolean isPaidFirstSource = keyItems[0].equals("0")? false : true;
|
- |
|
| 165 |
String firstSource = keyItems[1];
|
139 |
cal.add(Calendar.HOUR_OF_DAY, 6);
|
| 166 |
Boolean isPaidSessionSource = keyItems[2].equals("0")? false : true;
|
- |
|
| 167 |
String sessionSource = keyItems[3];
|
140 |
queryToDate = cal.getTime();
|
| 168 |
Long catalogItemId = Long.parseLong(keyItems[4]);
|
- |
|
| 169 |
|
141 |
|
| 170 |
ItemActivityWithSource itemActivity = new ItemActivityWithSource();
|
- |
|
| 171 |
itemActivity.setIsPaidFirstSource(isPaidFirstSource);
|
142 |
logger.warning("From Query Date : " + queryFromDate);
|
| 172 |
itemActivity.setFirstSource(firstSource);
|
- |
|
| 173 |
itemActivity.setIsPaidSessionSource(isPaidSessionSource);
|
- |
|
| 174 |
itemActivity.setSessionSource(sessionSource);
|
- |
|
| 175 |
itemActivity.setCatalogId(catalogItemId);
|
- |
|
| 176 |
itemActivity.setDate(fromDate);
|
143 |
logger.warning("To Query Date : " + queryToDate);
|
| 177 |
|
144 |
|
| - |
|
145 |
logger.warning("DailyProductWithSourceAggregator : Updating View Count Map");
|
| - |
|
146 |
UpdateViewCount(PRODUCT_VIEW_EVENT, VIEW_COUNT_KEY,
|
| - |
|
147 |
UNIQUE_VIEW_COUNT_KEY);
|
| - |
|
148 |
logger.warning("DailyProductWithSourceAggregator : itemsResultMap size : "
|
| - |
|
149 |
+ itemsResultMap.size());
|
| - |
|
150 |
logger.warning("DailyProductWithSourceAggregator : sessionIdSourceMap size : "
|
| - |
|
151 |
+ sessionIdSourceMap.size());
|
| - |
|
152 |
|
| - |
|
153 |
logger.warning("DailyProductWithSourceAggregator : Updating Add To Cart Count Map");
|
| - |
|
154 |
UpdateItemIdEventCount(ADD_TO_CART_EVENT, ADD_TO_CART_COUNT_KEY,
|
| - |
|
155 |
UNIQUE_ADD_TO_CART_COUNT_KEY, false);
|
| - |
|
156 |
logger.warning("DailyProductWithSourceAggregator : Updating Delete From Cart Count Map");
|
| - |
|
157 |
UpdateItemIdEventCount(DELETE_FROM_CART_EVENT,
|
| - |
|
158 |
DELETE_FROM_CART_COUNT_KEY,
|
| - |
|
159 |
UNIQUE_DELETE_FROM_CART_COUNT_KEY, false);
|
| - |
|
160 |
logger.warning("DailyProductWithSourceAggregator : Updating Add To Research Count Map");
|
| - |
|
161 |
UpdateItemIdEventCount(RESEARCH_ADD_EVENT,
|
| - |
|
162 |
ADD_TO_RESEARCH_COUNT_KEY,
|
| - |
|
163 |
UNIQUE_ADD_TO_RESEARCH_COUNT_KEY, true);
|
| - |
|
164 |
logger.warning("DailyProductWithSourceAggregator : Updating Delete From Research Count Map");
|
| - |
|
165 |
UpdateItemIdEventCount(RESEARCH_DELETE_EVENT,
|
| - |
|
166 |
DELETE_FROM_RESEARCH_COUNT_KEY,
|
| - |
|
167 |
UNIQUE_DELETE_FROM_RESEARCH_COUNT_KEY, true);
|
| - |
|
168 |
|
| - |
|
169 |
logger.warning("DailyProductWithSourceAggregator : Updating ShippingAccessCount Count Map");
|
| - |
|
170 |
UpdateItemIdEventCount(SHIPPING_ACCESS_EVENT,
|
| - |
|
171 |
SHIPPING_ACCESS_COUNT_KEY,
|
| - |
|
172 |
UNIQUE_SHIPPING_ACCESS_COUNT_KEY, false);
|
| - |
|
173 |
logger.warning("DailyProductWithSourceAggregator : Updating Payment Success Count Map");
|
| - |
|
174 |
UpdateItemIdEventCount(PAYMENT_SUCCESS_EVENT,
|
| - |
|
175 |
PAYMENT_SUCCESS_COUNT_KEY,
|
| - |
|
176 |
UNIQUE_PAYMENT_SUCCESS_COUNT_KEY, false);
|
| - |
|
177 |
logger.warning("DailyProductWithSourceAggregator : Updating Order Creation Count Map");
|
| - |
|
178 |
UpdateItemIdEventCount(ORDER_CREATION_EVENT,
|
| - |
|
179 |
ORDER_CREATION_COUNT_KEY, UNIQUE_ORDER_CREATION_COUNT_KEY,
|
| - |
|
180 |
false);
|
| - |
|
181 |
logger.warning("DailyProductWithSourceAggregator : Updating Payment Failure Count Map");
|
| - |
|
182 |
UpdateItemIdEventCount(PAYMENT_FAILURE_EVENT,
|
| - |
|
183 |
PAYMENT_FAILURE_COUNT_KEY,
|
| - |
|
184 |
UNIQUE_PAYMENT_FAILURE_COUNT_KEY, false);
|
| - |
|
185 |
logger.warning("DailyProductWithSourceAggregator : Updating Proceed To Pay Count Map");
|
| - |
|
186 |
UpdateItemIdEventCount(PROCEED_TO_PAY_EVENT,
|
| - |
|
187 |
PROCEED_TO_PAY_COUNT_KEY, UNIQUE_PROCEED_TO_PAY_COUNT_KEY,
|
| - |
|
188 |
false);
|
| - |
|
189 |
|
| - |
|
190 |
List<ItemActivityWithSource> itemActivities = new ArrayList<ItemActivityWithSource>();
|
| - |
|
191 |
ItemActivityWithSourceRepository itemActivityRepository = new ItemActivityWithSourceRepository();
|
| - |
|
192 |
for (Entry<String, Map<String, Long>> entry : itemsResultMap
|
| - |
|
193 |
.entrySet()) {
|
| - |
|
194 |
String key = (String) entry.getKey();
|
| - |
|
195 |
Map<String, Long> itemMap = (Map<String, Long>) entry
|
| - |
|
196 |
.getValue();
|
| - |
|
197 |
|
| - |
|
198 |
String[] keyItems = key.split("_");
|
| - |
|
199 |
|
| - |
|
200 |
Boolean isPaidFirstSource = keyItems[0].equals("0") ? false
|
| - |
|
201 |
: true;
|
| - |
|
202 |
String firstSource = keyItems[1];
|
| - |
|
203 |
Boolean isPaidSessionSource = keyItems[2].equals("0") ? false
|
| - |
|
204 |
: true;
|
| - |
|
205 |
String sessionSource = keyItems[3];
|
| - |
|
206 |
Long catalogItemId = Long.parseLong(keyItems[4]);
|
| - |
|
207 |
|
| - |
|
208 |
ItemActivityWithSource itemActivity = new ItemActivityWithSource();
|
| - |
|
209 |
itemActivity.setIsPaidFirstSource(isPaidFirstSource);
|
| - |
|
210 |
itemActivity.setFirstSource(firstSource);
|
| - |
|
211 |
itemActivity.setIsPaidSessionSource(isPaidSessionSource);
|
| - |
|
212 |
itemActivity.setSessionSource(sessionSource);
|
| - |
|
213 |
itemActivity.setCatalogId(catalogItemId);
|
| - |
|
214 |
itemActivity.setDate(fromDate);
|
| - |
|
215 |
|
| 178 |
itemActivity.setView(itemMap.get(VIEW_COUNT_KEY));
|
216 |
itemActivity.setView(itemMap.get(VIEW_COUNT_KEY));
|
| 179 |
itemActivity.setAddToCart(itemMap.get(ADD_TO_CART_COUNT_KEY));
|
217 |
itemActivity.setAddToCart(itemMap.get(ADD_TO_CART_COUNT_KEY));
|
| - |
|
218 |
itemActivity.setAddToResearch(itemMap
|
| 180 |
itemActivity.setAddToResearch(itemMap.get(ADD_TO_RESEARCH_COUNT_KEY));
|
219 |
.get(ADD_TO_RESEARCH_COUNT_KEY));
|
| - |
|
220 |
itemActivity.setDeleteFromCart(itemMap
|
| 181 |
itemActivity.setDeleteFromCart(itemMap.get(DELETE_FROM_CART_COUNT_KEY));
|
221 |
.get(DELETE_FROM_CART_COUNT_KEY));
|
| - |
|
222 |
itemActivity.setDeleteFromResearch(itemMap
|
| 182 |
itemActivity.setDeleteFromResearch(itemMap.get(DELETE_FROM_RESEARCH_COUNT_KEY));
|
223 |
.get(DELETE_FROM_RESEARCH_COUNT_KEY));
|
| 183 |
itemActivity.setShippingAccess(itemMap.get(SHIPPING_ACCESS_COUNT_KEY));
|
224 |
itemActivity.setShippingAccess(itemMap
|
| - |
|
225 |
.get(SHIPPING_ACCESS_COUNT_KEY));
|
| 184 |
itemActivity.setPaymentSuccess(itemMap.get(PAYMENT_SUCCESS_COUNT_KEY));
|
226 |
itemActivity.setPaymentSuccess(itemMap
|
| - |
|
227 |
.get(PAYMENT_SUCCESS_COUNT_KEY));
|
| 185 |
itemActivity.setOrderCreation(itemMap.get(ORDER_CREATION_COUNT_KEY));
|
228 |
itemActivity.setOrderCreation(itemMap
|
| - |
|
229 |
.get(ORDER_CREATION_COUNT_KEY));
|
| 186 |
itemActivity.setPaymentFailure(itemMap.get(PAYMENT_FAILURE_COUNT_KEY));
|
230 |
itemActivity.setPaymentFailure(itemMap
|
| - |
|
231 |
.get(PAYMENT_FAILURE_COUNT_KEY));
|
| 187 |
itemActivity.setProceedToPay(itemMap.get(PROCEED_TO_PAY_COUNT_KEY));
|
232 |
itemActivity.setProceedToPay(itemMap
|
| 188 |
|
233 |
.get(PROCEED_TO_PAY_COUNT_KEY));
|
| - |
|
234 |
|
| 189 |
itemActivity.setUniqueView(itemMap.get(UNIQUE_VIEW_COUNT_KEY));
|
235 |
itemActivity.setUniqueView(itemMap.get(UNIQUE_VIEW_COUNT_KEY));
|
| - |
|
236 |
itemActivity.setUniqueAddToCart(itemMap
|
| 190 |
itemActivity.setUniqueAddToCart(itemMap.get(UNIQUE_ADD_TO_CART_COUNT_KEY));
|
237 |
.get(UNIQUE_ADD_TO_CART_COUNT_KEY));
|
| - |
|
238 |
itemActivity.setUniqueAddToResearch(itemMap
|
| 191 |
itemActivity.setUniqueAddToResearch(itemMap.get(UNIQUE_ADD_TO_RESEARCH_COUNT_KEY));
|
239 |
.get(UNIQUE_ADD_TO_RESEARCH_COUNT_KEY));
|
| - |
|
240 |
itemActivity.setUniqueDeleteFromCart(itemMap
|
| 192 |
itemActivity.setUniqueDeleteFromCart(itemMap.get(UNIQUE_DELETE_FROM_CART_COUNT_KEY));
|
241 |
.get(UNIQUE_DELETE_FROM_CART_COUNT_KEY));
|
| 193 |
itemActivity.setUniqueDeleteFromResearch(itemMap.get(UNIQUE_ADD_TO_RESEARCH_COUNT_KEY));
|
242 |
itemActivity.setUniqueDeleteFromResearch(itemMap
|
| 194 |
itemActivity.setUniqueShippingAccess(itemMap.get(UNIQUE_SHIPPING_ACCESS_COUNT_KEY));
|
243 |
.get(UNIQUE_ADD_TO_RESEARCH_COUNT_KEY));
|
| 195 |
itemActivity.setUniquePaymentSuccess(itemMap.get(UNIQUE_PAYMENT_SUCCESS_COUNT_KEY));
|
244 |
itemActivity.setUniqueShippingAccess(itemMap
|
| 196 |
itemActivity.setUniqueOrderCreation(itemMap.get(UNIQUE_ORDER_CREATION_COUNT_KEY));
|
245 |
.get(UNIQUE_SHIPPING_ACCESS_COUNT_KEY));
|
| 197 |
itemActivity.setUniquePaymentFailure(itemMap.get(UNIQUE_PAYMENT_FAILURE_COUNT_KEY));
|
246 |
itemActivity.setUniquePaymentSuccess(itemMap
|
| 198 |
itemActivity.setUniqueProceedToPay(itemMap.get(UNIQUE_PROCEED_TO_PAY_COUNT_KEY));
|
247 |
.get(UNIQUE_PAYMENT_SUCCESS_COUNT_KEY));
|
| 199 |
|
- |
|
| 200 |
itemActivities.add(itemActivity);
|
248 |
itemActivity.setUniqueOrderCreation(itemMap
|
| 201 |
|
249 |
.get(UNIQUE_ORDER_CREATION_COUNT_KEY));
|
| 202 |
if (itemActivities.size()>500) {
|
250 |
itemActivity.setUniquePaymentFailure(itemMap
|
| 203 |
logger.warning("DailyProductWithSourceAggregator : persisting itemactivities : " + itemActivities.size());
|
251 |
.get(UNIQUE_PAYMENT_FAILURE_COUNT_KEY));
|
| 204 |
itemActivityRepository.createAll(itemActivities);
|
252 |
itemActivity.setUniqueProceedToPay(itemMap
|
| - |
|
253 |
.get(UNIQUE_PROCEED_TO_PAY_COUNT_KEY));
|
| - |
|
254 |
|
| 205 |
itemActivities.clear();
|
255 |
itemActivities.add(itemActivity);
|
| - |
|
256 |
|
| 206 |
}
|
257 |
}
|
| - |
|
258 |
logger.warning("DailyProductWithSourceAggregator : persisting itemactivities : "
|
| - |
|
259 |
+ itemActivities.size());
|
| - |
|
260 |
logger.warning("DailyProductWithSourceAggregator : itemactivities : "
|
| - |
|
261 |
+ itemActivities);
|
| - |
|
262 |
itemActivityRepository.createAll(itemActivities);
|
| 207 |
}
|
263 |
}
|
| 208 |
logger.warning("DailyProductWithSourceAggregator : persisting itemactivities : " + itemActivities.size());
|
- |
|
| 209 |
logger.warning("DailyProductWithSourceAggregator : itemactivities : " + itemActivities);
|
- |
|
| 210 |
itemActivityRepository.createAll(itemActivities);
|
- |
|
| 211 |
}
|
264 |
}
|
| 212 |
|
265 |
|
| 213 |
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
266 |
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
| 214 |
doPost(req, resp);
|
267 |
doPost(req, resp);
|
| 215 |
}
|
268 |
}
|
| 216 |
|
269 |
|
| 217 |
private void UpdateViewCount(String event, String viewCountKey, String uniqueViewCountKey) {
|
270 |
private void UpdateViewCount(String event, String viewCountKey, String uniqueViewCountKey) {
|
| 218 |
Query query = new Query(KIND);
|
271 |
Query query = new Query(KIND);
|
| 219 |
query.addFilter(EVENTTYPE_FIELD, Query.FilterOperator.EQUAL, event);
|
272 |
query.addFilter(EVENTTYPE_FIELD, Query.FilterOperator.EQUAL, event);
|
| 220 |
query.addFilter(DATE_FIELD, Query.FilterOperator.GREATER_THAN_OR_EQUAL, fromDate);
|
273 |
query.addFilter(DATE_FIELD, Query.FilterOperator.GREATER_THAN_OR_EQUAL, queryFromDate);
|
| 221 |
query.addFilter(DATE_FIELD, Query.FilterOperator.LESS_THAN, toDate);
|
274 |
query.addFilter(DATE_FIELD, Query.FilterOperator.LESS_THAN, queryToDate);
|
| 222 |
PreparedQuery pq = datastore.prepare(query);
|
275 |
PreparedQuery pq = datastore.prepare(query);
|
| 223 |
Set<String> uniqueSet = new HashSet<String>();
|
276 |
Set<String> uniqueSet = new HashSet<String>();
|
| 224 |
List<Entity> entityResults = new ArrayList<Entity>();
|
277 |
List<Entity> entityResults = new ArrayList<Entity>();
|
| 225 |
|
278 |
|
| 226 |
Set<String> sessionIds = new HashSet<String>();
|
279 |
Set<String> sessionIds = new HashSet<String>();
|
| 227 |
logger.warning("DailyProductWithSourceAggregator : Getting View Events in list");
|
280 |
logger.warning("DailyProductWithSourceAggregator : Getting View Events in list");
|
| 228 |
for (Entity e : pq.asList(FetchOptions.Builder.withChunkSize(500))) {
|
281 |
for (Entity e : pq.asIterable(FetchOptions.Builder.withChunkSize(500))) {
|
| 229 |
entityResults.add(e);
|
282 |
entityResults.add(e);
|
| - |
|
283 |
}
|
| - |
|
284 |
for (Entity e : entityResults) {
|
| 230 |
String sessionId = (String)e.getProperty(SESSION_ID_FIELD);
|
285 |
String sessionId = (String)e.getProperty(SESSION_ID_FIELD);
|
| 231 |
if (sessionId != null && !sessionId.isEmpty()) {
|
286 |
if (sessionId != null && !sessionId.isEmpty()) {
|
| 232 |
sessionIds.add(sessionId);
|
287 |
sessionIds.add(sessionId);
|
| 233 |
}
|
288 |
}
|
| 234 |
}
|
289 |
}
|
| Line 292... |
Line 347... |
| 292 |
private void populateSessionIdSourceMap(Set<String> sessionIds) {
|
347 |
private void populateSessionIdSourceMap(Set<String> sessionIds) {
|
| 293 |
|
348 |
|
| 294 |
Query sessionQuery = new Query(KIND);
|
349 |
Query sessionQuery = new Query(KIND);
|
| 295 |
sessionQuery.addFilter(EVENTTYPE_FIELD, Query.FilterOperator.EQUAL,
|
350 |
sessionQuery.addFilter(EVENTTYPE_FIELD, Query.FilterOperator.EQUAL,
|
| 296 |
NEW_SESSION_EVENT);
|
351 |
NEW_SESSION_EVENT);
|
| 297 |
sessionQuery.addFilter(DATE_FIELD, Query.FilterOperator.GREATER_THAN_OR_EQUAL, fromDate);
|
352 |
sessionQuery.addFilter(DATE_FIELD, Query.FilterOperator.GREATER_THAN_OR_EQUAL, queryFromDate);
|
| 298 |
sessionQuery.addFilter(DATE_FIELD, Query.FilterOperator.LESS_THAN, toDate);
|
353 |
sessionQuery.addFilter(DATE_FIELD, Query.FilterOperator.LESS_THAN, queryToDate);
|
| 299 |
|
354 |
|
| 300 |
PreparedQuery sessionPq = datastore.prepare(sessionQuery);
|
355 |
PreparedQuery sessionPq = datastore.prepare(sessionQuery);
|
| - |
|
356 |
|
| - |
|
357 |
List<Entity> entityResults = new ArrayList<Entity>();
|
| - |
|
358 |
for (Entity e : sessionPq.asIterable(FetchOptions.Builder.withChunkSize(500))) {
|
| - |
|
359 |
entityResults.add(e);
|
| - |
|
360 |
}
|
| - |
|
361 |
|
| 301 |
for (Entity sessionResult : sessionPq.asIterable()) {
|
362 |
for (Entity sessionResult : entityResults) {
|
| 302 |
String sessionId = (String)sessionResult.getProperty(SESSION_ID_FIELD);
|
363 |
String sessionId = (String)sessionResult.getProperty(SESSION_ID_FIELD);
|
| 303 |
if (sessionIds.contains(sessionId)) {
|
364 |
if (sessionIds.contains(sessionId)) {
|
| 304 |
String firstSource = "";
|
365 |
String firstSource = "";
|
| 305 |
String sessionSource = "";
|
366 |
String sessionSource = "";
|
| 306 |
if (sessionResult != null) {
|
367 |
if (sessionResult != null) {
|
| Line 365... |
Line 426... |
| 365 |
}
|
426 |
}
|
| 366 |
|
427 |
|
| 367 |
private void UpdateItemIdEventCount(String event, String countKey, String uniqueCountKey, boolean isCatalogIdEvent) {
|
428 |
private void UpdateItemIdEventCount(String event, String countKey, String uniqueCountKey, boolean isCatalogIdEvent) {
|
| 368 |
Query query = new Query(KIND);
|
429 |
Query query = new Query(KIND);
|
| 369 |
query.addFilter(EVENTTYPE_FIELD, Query.FilterOperator.EQUAL, event);
|
430 |
query.addFilter(EVENTTYPE_FIELD, Query.FilterOperator.EQUAL, event);
|
| 370 |
query.addFilter(DATE_FIELD, Query.FilterOperator.GREATER_THAN_OR_EQUAL, fromDate);
|
431 |
query.addFilter(DATE_FIELD, Query.FilterOperator.GREATER_THAN_OR_EQUAL, queryFromDate);
|
| 371 |
query.addFilter(DATE_FIELD, Query.FilterOperator.LESS_THAN, toDate);
|
432 |
query.addFilter(DATE_FIELD, Query.FilterOperator.LESS_THAN, queryToDate);
|
| 372 |
PreparedQuery pq = datastore.prepare(query);
|
433 |
PreparedQuery pq = datastore.prepare(query);
|
| 373 |
Set<String> uniqueSet = new HashSet<String>();
|
434 |
Set<String> uniqueSet = new HashSet<String>();
|
| 374 |
List<Entity> results = new ArrayList<Entity>();
|
435 |
List<Entity> results = new ArrayList<Entity>();
|
| 375 |
for (Entity e : pq.asList(FetchOptions.Builder.withChunkSize(500))) {
|
436 |
for (Entity e : pq.asList(FetchOptions.Builder.withChunkSize(500))) {
|
| 376 |
results.add(e);
|
437 |
results.add(e);
|