Plugin Directory

Changeset 2253191


Ignore:
Timestamp:
03/02/2020 07:52:25 PM (6 years ago)
Author:
salar6990
Message:

update trunk

Location:
wp-api-stats/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-api-stats/trunk/class-wp-api-stats.php

    r2139630 r2253191  
    9898
    9999        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') );
    101101        }
    102102
     
    148148           
    149149            $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
    153152            foreach($methods as $method){
    154153                $c = 0;
    155154                foreach($results as $entry){
    156155                    if( $entry->method == $method){
    157                         $c++;
     156                        $c+=1;
    158157                    }
    159158                }
     159                $count += $c;
    160160                $data[$method][] = $c;
    161161            }
     
    172172           
    173173        }
    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');
    176189
    177190        return $this->prepared_data;
     
    197210        extract($this->prepare_data());
    198211        include __DIR__ . '/views/admin-panel.php';
     212        include __DIR__ . '/views/table.php';
    199213    }
    200214
     
    206220        wp_enqueue_script('chartjs', plugins_url('assets/chartjs/Chart.min.js', __FILE__), array(), '2.8.0' );
    207221        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
    208224    }
    209225
  • wp-api-stats/trunk/readme.txt

    r2148600 r2253191  
    33Tags: API REST-API Statistics stats
    44Requires at least: 4.4
    5 Tested up to: 5.2.2
     5Tested up to: 5.3.2
    66Requires PHP: 5.6
    77License: GPLv3
    88License URI: https://www.gnu.org/licenses/gpl-3.0.html
    9 Stable Tag: 1.2.0
     9Stable Tag: 1.3.0
    1010
    1111View API calls to your website
  • wp-api-stats/trunk/wp-api-stats.php

    r2139630 r2253191  
    11<?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/*
     3Plugin Name: WP API Stats
     4Description: Track and Analyse WordPress API calls and requests.
     5Author: Salar Gholizadeh
     6Version: 1.3.0
     7Plugin URI: https://github.com/salar90/wp-api-stats
     8Author URI: http://salar.one/
     9License: GNU General Public License v3.0
     10License URI: http://www.gnu.org/licenses/gpl-3.0.txt
     11Text Domain: api-stats
     12Domain Path: /languages
    1413 */
    1514
Note: See TracChangeset for help on using the changeset viewer.