@@ -137,7 +137,7 @@ public function get_posts(string $start_date, string $end_date, int $offset = 0,
137137
138138 return array_map (function ($ row ) {
139139 $ row ->pageviews = (int ) $ row ->pageviews ;
140- $ row ->visitors = ( int ) $ row ->visitors ;
140+ $ row ->visitors = max ( 1 , ( int ) $ row ->visitors ) ;
141141
142142 // for backwards compatibility with versions before 2.0
143143 // set post_title and post_permalink property
@@ -170,7 +170,12 @@ public function get_referrers(string $start_date, string $end_date, int $offset
170170 {
171171 /** @var wpdb $wpdb */
172172 global $ wpdb ;
173- return $ wpdb ->get_results ($ wpdb ->prepare (
173+
174+ return array_map (function ($ row ) {
175+ $ row ->pageviews = (int ) $ row ->pageviews ;
176+ $ row ->visitors = max (1 , (int ) $ row ->visitors );
177+ return $ row ;
178+ }, $ wpdb ->get_results ($ wpdb ->prepare (
174179 "SELECT s.id, url, SUM(visitors) As visitors, SUM(pageviews) AS pageviews
175180 FROM {$ wpdb ->prefix }koko_analytics_referrer_stats s
176181 JOIN {$ wpdb ->prefix }koko_analytics_referrer_urls r ON r.id = s.id
@@ -179,7 +184,7 @@ public function get_referrers(string $start_date, string $end_date, int $offset
179184 ORDER BY pageviews DESC, r.id ASC
180185 LIMIT %d, %d " ,
181186 [$ start_date , $ end_date , $ offset , $ limit ]
182- ));
187+ ))) ;
183188 }
184189
185190 public function count_referrers (string $ start_date , string $ end_date ): int
0 commit comments