public function refreshValues()
 {
     $this->conversion_rate = MathHelper::calcConvRate($this->conversions, $this->clicks);
     $this->cost_per_conversion = MathHelper::calcCostConv($this->cost, $this->conversions);
     $this->conversion_rate_many_per_click = MathHelper::calcConvRate($this->conversions_many_per_click, $this->clicks);
     $this->cost_per_conversion_many_per_click = MathHelper::calcCostConv($this->cost, $this->conversions_many_per_click);
     parent::refreshValues();
 }
Пример #2
0
 public static function genStats($override = array())
 {
     $object_id = rand(0, 1000) . time();
     $name = md5($object_id);
     $time_start = new DateTime('-' . rand(1, 31) . ' days');
     $time_end = new DateTime('now');
     $clicks = rand(0, 3000);
     $impressions = $clicks * rand(10, 30);
     $cost = $clicks * (rand(10, 120) / 100);
     extract($override);
     $stats = new Stats();
     $stats->object_id = $object_id;
     $stats->name = $name;
     $stats->time_start = $time_start;
     $stats->time_end = $time_end;
     $stats->clicks = $clicks;
     $stats->impressions = $impressions;
     $stats->cost = $cost;
     $stats->refreshValues();
     return $stats;
 }
Пример #3
0
 public function testMerge()
 {
     $time_start = new \DateTime('-6 days');
     $stats2 = new Stats();
     $stats2->object_id = 1;
     $stats2->name = 'Teste de Merge';
     $stats2->time_start = $time_start;
     $stats2->time_end = new \DateTime('-1 day');
     $stats2->clicks = 100;
     $stats2->impressions = 2000;
     $stats2->cost = 234.8;
     $this->stats->merge($stats2);
     $now = new \DateTime('now');
     $this->assertEquals($time_start->getTimestamp(), $this->stats->time_start->getTimestamp());
     $this->assertEquals($now->getTimestamp(), $this->stats->time_end->getTimestamp());
     $this->assertEquals(976, $this->stats->clicks);
     $this->assertEquals(395372, $this->stats->impressions);
     $this->assertEquals(1762.89, $this->stats->cost);
     $this->assertEquals(1.8062397540984, $this->stats->cpc);
     $this->assertEquals(0.24685612537054, $this->stats->ctr);
 }
 /**
  * @param Stats $stats
  *
  * @return Stats
  */
 public function merge(\ebussola\ads\reports\Stats $stats)
 {
     $this->social_impressions = $this->social_impressions + $stats->social_impressions;
     $this->social_clicks = $this->social_clicks + $stats->social_clicks;
     $this->unique_impressions = $this->unique_impressions + $stats->unique_impressions;
     $this->unique_clicks = $this->unique_clicks + $stats->unique_clicks;
     $this->unique_social_impressions = $this->unique_social_impressions + $stats->unique_social_impressions;
     $this->unique_social_clicks = $this->unique_social_clicks + $stats->unique_social_clicks;
     $this->app_engagement = $this->app_engagement + $stats->app_engagement;
     $this->app_story = $this->app_story + $stats->app_story;
     $this->page_engagement = $this->page_engagement + $stats->page_engagement;
     $this->post_engagement = $this->post_engagement + $stats->post_engagement;
     $this->offsite_conversion = $this->offsite_conversion + $stats->offsite_conversion;
     $this->app_custom_event = $this->app_custom_event + $stats->app_custom_event;
     parent::merge($stats);
 }