@@ -262,13 +262,107 @@ public function pushMessagesAction() {
262
262
* @Route("push/data/app_open_graph", defaults={"_format": "json"}, name="dabsquared_push_notifications_data_app_open_graph")
263
263
* @Method("POST")
264
264
* @RequestParam(name="device_state", description="What device state to grab", strict=true)
265
- * @RequestParam(name="internal_app_ids", description="The vendor device identifier of the Android device.", strict=true, array=true)
265
+ * @RequestParam(name="internal_app_ids", description="The internal app ids to see information for.", strict=true, array=true)
266
+ * @RequestParam(name="device_types", description="The device types to show data for", strict=true, array=true)
267
+ * @RequestParam(name="start_date", description="Start date", strict=false)
268
+ * @RequestParam(name="end_date", description="End date", strict=false)
266
269
*/
267
270
public function getAppOpenGraphDataAction (ParamFetcher $ paramFetcher ) {
268
271
$ deviceState = $ paramFetcher ->get ('device_state ' );
269
272
$ internalAppIds = $ paramFetcher ->get ('internal_app_ids ' );
273
+ $ deviceTypes = $ paramFetcher ->get ('device_types ' );
274
+ $ startDate = $ paramFetcher ->get ('start_date ' );
275
+ $ endDate = $ paramFetcher ->get ('end_date ' );
276
+
277
+ if (is_null ($ startDate )) {
278
+ $ date = new \DateTime ('NOW ' );
279
+ $ date ->modify ('-1 week ' );
280
+ $ startDate = $ date ;
281
+ } else {
282
+ $ startDate = new \DateTime ($ startDate );
283
+ }
284
+
285
+ if (is_null ($ endDate )) {
286
+ $ endDate = new \DateTime ('NOW ' );
287
+ }else {
288
+ $ endDate = new \DateTime ($ endDate );
289
+ }
290
+
291
+
292
+ $ appEvents = $ this ->appEventManager ->getAppEvents (array (AppEventInterface::APP_OPEN ), $ deviceTypes , $ internalAppIds , $ deviceState , $ startDate , $ endDate );
293
+ $ appEventDayCounts = array ();
294
+
295
+ /** @var $appEvent \DABSquared\PushNotificationsBundle\Model\AppEventInterface */
296
+ foreach ($ appEvents as $ appEvent ) {
297
+ $ day = $ appEvent ->getCreatedAt ()->format ('Y-m-d ' );
298
+ $ appId = $ appEvent ->getDevice ()->getAppId ();
299
+
300
+ if (!isset ($ appEventDayCounts [$ day ])) {
301
+ $ appEventDayCounts [$ day ] = array ();
302
+ }
303
+
304
+ if (!isset ($ appEventDayCounts [$ day ][$ appId ])) {
305
+ $ appEventDayCounts [$ day ][$ appId ] = 0 ;
306
+ }
307
+
308
+ $ appEventDayCounts [$ day ][$ appId ] = $ appEventDayCounts [$ day ][$ appId ] + 1 ;
309
+ }
310
+
311
+ ksort ($ appEventDayCounts );
312
+
313
+ $ appEventCounts = array ();
314
+
315
+ foreach ($ appEventDayCounts as $ key => $ val ) {
316
+ $ tempPointArray = array ();
317
+ $ tempPointArray ['day ' ] = $ key ;
318
+
319
+ foreach ($ appEventDayCounts [$ key ] as $ key1 => $ val1 ) {
320
+ $ tempPointArray [$ key1 ] = $ val1 ;
321
+ }
322
+
323
+ $ appEventCounts [] = $ tempPointArray ;
324
+ }
325
+
326
+ return $ appEventCounts ;
327
+ }
328
+
329
+ /**
330
+ * @ApiDoc(
331
+ * description="Gets the data to be converted for the graph",
332
+ * section="DABSquared Push Notifications (Dashboard Data)"
333
+ * )
334
+ * @Rest\View()
335
+ * @Route("push/data/app_terminated_graph", defaults={"_format": "json"}, name="dabsquared_push_notifications_data_app_terminated_graph")
336
+ * @Method("POST")
337
+ * @RequestParam(name="device_state", description="What device state to grab", strict=true)
338
+ * @RequestParam(name="internal_app_ids", description="The internal app ids to see information for.", strict=true, array=true)
339
+ * @RequestParam(name="device_types", description="The device types to show data for", strict=true, array=true)
340
+ * @RequestParam(name="start_date", description="Start date", strict=false)
341
+ * @RequestParam(name="end_date", description="End date", strict=false)
342
+ */
343
+ public function getAppTerminatedGraphDataAction (ParamFetcher $ paramFetcher ) {
344
+ $ deviceState = $ paramFetcher ->get ('device_state ' );
345
+ $ internalAppIds = $ paramFetcher ->get ('internal_app_ids ' );
346
+ $ deviceTypes = $ paramFetcher ->get ('device_types ' );
347
+ $ startDate = $ paramFetcher ->get ('start_date ' );
348
+ $ endDate = $ paramFetcher ->get ('end_date ' );
349
+
350
+ if (is_null ($ startDate )) {
351
+ $ date = new \DateTime ('NOW ' );
352
+ $ date ->modify ('-1 week ' );
353
+ $ startDate = $ date ;
354
+ } else {
355
+ $ startDate = new \DateTime ($ startDate );
356
+ }
270
357
271
- $ appEvents = $ this ->appEventManager ->getAppEvents (array (AppEventInterface::APP_OPEN ), array (Types::OS_IOS ), $ internalAppIds , $ deviceState , new \DateTime ('2005-08-15T15:52:01+00:00 ' ), new \DateTime ('2015-08-15T15:52:01+00:00 ' ));
358
+ if (is_null ($ endDate )) {
359
+ $ endDate = new \DateTime ('NOW ' );
360
+ }else {
361
+ $ endDate = new \DateTime ($ endDate );
362
+ }
363
+
364
+
365
+ $ appEvents = $ this ->appEventManager ->getAppEvents (array (AppEventInterface::APP_TERMINATED ), $ deviceTypes , $ internalAppIds , $ deviceState , $ startDate , $ endDate );
272
366
$ appEventDayCounts = array ();
273
367
274
368
/** @var $appEvent \DABSquared\PushNotificationsBundle\Model\AppEventInterface */
@@ -305,6 +399,78 @@ public function getAppOpenGraphDataAction(ParamFetcher $paramFetcher) {
305
399
return $ appEventCounts ;
306
400
}
307
401
402
+ /**
403
+ * @ApiDoc(
404
+ * description="Gets the data to be converted for the graph",
405
+ * section="DABSquared Push Notifications (Dashboard Data)"
406
+ * )
407
+ * @Rest\View()
408
+ * @Route("push/data/app_backgrounded_graph", defaults={"_format": "json"}, name="dabsquared_push_notifications_data_app_backgrounded_graph")
409
+ * @Method("POST")
410
+ * @RequestParam(name="device_state", description="What device state to grab", strict=true)
411
+ * @RequestParam(name="internal_app_ids", description="The internal app ids to see information for.", strict=true, array=true)
412
+ * @RequestParam(name="device_types", description="The device types to show data for", strict=true, array=true)
413
+ * @RequestParam(name="start_date", description="Start date", strict=false)
414
+ * @RequestParam(name="end_date", description="End date", strict=false)
415
+ */
416
+ public function getAppBackgroundedGraphDataAction (ParamFetcher $ paramFetcher ) {
417
+ $ deviceState = $ paramFetcher ->get ('device_state ' );
418
+ $ internalAppIds = $ paramFetcher ->get ('internal_app_ids ' );
419
+ $ deviceTypes = $ paramFetcher ->get ('device_types ' );
420
+ $ startDate = $ paramFetcher ->get ('start_date ' );
421
+ $ endDate = $ paramFetcher ->get ('end_date ' );
422
+
423
+ if (is_null ($ startDate )) {
424
+ $ date = new \DateTime ('NOW ' );
425
+ $ date ->modify ('-1 week ' );
426
+ $ startDate = $ date ;
427
+ } else {
428
+ $ startDate = new \DateTime ($ startDate );
429
+ }
430
+
431
+ if (is_null ($ endDate )) {
432
+ $ endDate = new \DateTime ('NOW ' );
433
+ }else {
434
+ $ endDate = new \DateTime ($ endDate );
435
+ }
436
+
437
+
438
+ $ appEvents = $ this ->appEventManager ->getAppEvents (array (AppEventInterface::APP_BACKGROUNDED ), $ deviceTypes , $ internalAppIds , $ deviceState , $ startDate , $ endDate );
439
+ $ appEventDayCounts = array ();
440
+
441
+ /** @var $appEvent \DABSquared\PushNotificationsBundle\Model\AppEventInterface */
442
+ foreach ($ appEvents as $ appEvent ) {
443
+ $ day = $ appEvent ->getCreatedAt ()->format ('Y-m-d ' );
444
+ $ appId = $ appEvent ->getDevice ()->getAppId ();
445
+
446
+ if (!isset ($ appEventDayCounts [$ day ])) {
447
+ $ appEventDayCounts [$ day ] = array ();
448
+ }
449
+
450
+ if (!isset ($ appEventDayCounts [$ day ][$ appId ])) {
451
+ $ appEventDayCounts [$ day ][$ appId ] = 0 ;
452
+ }
453
+
454
+ $ appEventDayCounts [$ day ][$ appId ] = $ appEventDayCounts [$ day ][$ appId ] + 1 ;
455
+ }
456
+
457
+ ksort ($ appEventDayCounts );
458
+
459
+ $ appEventCounts = array ();
460
+
461
+ foreach ($ appEventDayCounts as $ key => $ val ) {
462
+ $ tempPointArray = array ();
463
+ $ tempPointArray ['day ' ] = $ key ;
464
+
465
+ foreach ($ appEventDayCounts [$ key ] as $ key1 => $ val1 ) {
466
+ $ tempPointArray [$ key1 ] = $ val1 ;
467
+ }
468
+
469
+ $ appEventCounts [] = $ tempPointArray ;
470
+ }
471
+
472
+ return $ appEventCounts ;
473
+ }
308
474
309
475
310
476
}
0 commit comments