Changeset 2253191
- Timestamp:
- 03/02/2020 07:52:25 PM (6 years ago)
- Location:
- wp-api-stats/trunk
- Files:
-
- 3 edited
-
class-wp-api-stats.php (modified) (5 diffs)
-
readme.txt (modified) (1 diff)
-
wp-api-stats.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-api-stats/trunk/class-wp-api-stats.php
r2139630 r2253191 98 98 99 99 if(empty($current_date_to)){ 100 $current_date_to = date('Y-m-d ',strtotime('today') );100 $current_date_to = date('Y-m-d 23:59:59',strtotime('today') ); 101 101 } 102 102 … … 148 148 149 149 $results = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}sg_api_stats_events WHERE time >= $q_start AND time < $q_end", OBJECT ); 150 $count = count($results); 151 152 150 $count = 0; 151 153 152 foreach($methods as $method){ 154 153 $c = 0; 155 154 foreach($results as $entry){ 156 155 if( $entry->method == $method){ 157 $c+ +;156 $c+=1; 158 157 } 159 158 } 159 $count += $c; 160 160 $data[$method][] = $c; 161 161 } … … 172 172 173 173 } 174 175 $this->prepared_data = compact('data', 'current_date_from', 'current_date_to', 'selected_chunk', 'labels'); 174 $query = "SELECT 175 e.method, 176 e.route, 177 COUNT(e.id) AS count, 178 AVG(e.duration) as average_duration 179 180 FROM {$wpdb->prefix}sg_api_stats_events e 181 182 WHERE e.time >= '$current_date_from' AND e.time < '$current_date_to' 183 GROUP BY e.method, e.route 184 ORDER BY count desc 185 "; 186 $tableData = $wpdb->get_results($query, OBJECT ); 187 188 $this->prepared_data = compact('data','tableData', 'current_date_from', 'current_date_to', 'selected_chunk', 'labels'); 176 189 177 190 return $this->prepared_data; … … 197 210 extract($this->prepare_data()); 198 211 include __DIR__ . '/views/admin-panel.php'; 212 include __DIR__ . '/views/table.php'; 199 213 } 200 214 … … 206 220 wp_enqueue_script('chartjs', plugins_url('assets/chartjs/Chart.min.js', __FILE__), array(), '2.8.0' ); 207 221 wp_enqueue_script('api-stats-draw', plugins_url('assets/draw.js', __FILE__), array('chartjs'), '1.0', true ); 222 wp_enqueue_style( 'api-stats', plugins_url('assets/api-stats.css', __FILE__)); 223 208 224 } 209 225 -
wp-api-stats/trunk/readme.txt
r2148600 r2253191 3 3 Tags: API REST-API Statistics stats 4 4 Requires at least: 4.4 5 Tested up to: 5. 2.25 Tested up to: 5.3.2 6 6 Requires PHP: 5.6 7 7 License: GPLv3 8 8 License URI: https://www.gnu.org/licenses/gpl-3.0.html 9 Stable Tag: 1. 2.09 Stable Tag: 1.3.0 10 10 11 11 View API calls to your website -
wp-api-stats/trunk/wp-api-stats.php
r2139630 r2253191 1 1 <?php 2 /** 3 * @wordpress-plugin 4 * Plugin Name: WP API Stats 5 * Plugin URI: https://github.com/salar90/wp-api-stats 6 * Description: Track and Analyse WordPress API calls and requests. 7 * Version: 1.2.0 8 * Author: Salar Gholizadeh 9 * Author URI: http://salar.one/ 10 * License: GPL-2.0+ 11 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 12 * Text Domain: api-stats 13 * Domain Path: /languages 2 /* 3 Plugin Name: WP API Stats 4 Description: Track and Analyse WordPress API calls and requests. 5 Author: Salar Gholizadeh 6 Version: 1.3.0 7 Plugin URI: https://github.com/salar90/wp-api-stats 8 Author URI: http://salar.one/ 9 License: GNU General Public License v3.0 10 License URI: http://www.gnu.org/licenses/gpl-3.0.txt 11 Text Domain: api-stats 12 Domain Path: /languages 14 13 */ 15 14
Note: See TracChangeset
for help on using the changeset viewer.