/** * @param \ebussola\ads\reports\Stats | AbstractStats $stats */ public function merge(\ebussola\ads\reports\Stats $stats) { $this->conversions += $stats->conversions; $this->view_through_conversion += $stats->view_through_conversion; $this->conversions_many_per_click += $stats->conversions_many_per_click; parent::merge($stats); }
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); }