Skip to content

Commit

Permalink
Cache dashboard, avoid running queries. (fix #3, fix #5) (#6)
Browse files Browse the repository at this point in the history
* Update to HM coding standards (fix #5).
* Cached dashboard (fix #3).
  • Loading branch information
dac514 authored and Ned Zimmerman committed Jun 9, 2017
1 parent cdf4c0f commit b9a0847
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 672 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea/
vendor
coverage.xml
21 changes: 21 additions & 0 deletions bin/cache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

if ( ! defined( 'ABSPATH' ) ) {
die( "Run this script with WP-CLI: `wp eval-file bin/cache.php` \n" );
}

set_time_limit( 0 );

$cache_key = \PressbooksStats\Stats\get_admin_page_html_cache_key();

delete_site_transient( $cache_key );

\PressbooksStats\Stats\cache_stats_admin_page();

$html = get_site_transient( \PressbooksStats\Stats\get_admin_page_html_cache_key() );

if ( empty( $html ) ) {
echo "Failed to cache the stats dashboard... \n";
} else {
echo "Successfully cached the stats dashboard! \n";
}
11 changes: 4 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@
"docs": "https://github.com/pressbooks/pressbooks-stats/wiki"
},
"require-dev": {
"phpunit/phpunit": "5.5",
"squizlabs/php_codesniffer": "2.7",
"wp-coding-standards/wpcs": "0.10"
"phpunit/phpunit": "~5.5",
"humanmade/coding-standards": "^0.2.1"
},
"scripts": {
"test": [
"vendor/bin/phpunit --configuration phpunit.xml --coverage-clover coverage.xml",
"vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs",
"vendor/bin/phpcs --standard=phpcs.xml --extensions=php ."
"@standards"
],
"standards": [
"vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs",
"vendor/bin/phpcs --standard=phpcs.xml --extensions=php ."
"vendor/bin/phpcs --standard=phpcs.ruleset.xml *.php inc/ bin/"
]
},
"require": {
Expand Down
Loading

0 comments on commit b9a0847

Please sign in to comment.