From ca2ffd065c9ebcc05a29ca7c43009480f1619dc3 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 19 Nov 2021 16:02:57 +0000 Subject: [PATCH] editcounts: Add button to update site stats --- editcounts.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/editcounts.php b/editcounts.php index 519bf3dd..300e3ce7 100644 --- a/editcounts.php +++ b/editcounts.php @@ -51,10 +51,27 @@ if ( !$results ) { die( $mysqli->error ); } + +$update = isset( $_POST['update'] ); + +echo '
'; + $wikis = []; while ( $data = $results->fetch_assoc() ) { $wiki = $data['wiki']; $wikis[$wiki] = $data; + + if ( $update ) { + $cmd = make_shell_command( + [ + 'PATCHDEMO' => __DIR__, + 'NAME' => $wiki, + ], + 'sh -c \'php $PATCHDEMO/wikis/$NAME/w/maintenance/initSiteStats.php --update --active\'' + ); + shell_echo( $cmd ); + } + $stats = $mysqli->query( " SELECT *, ( SELECT MAX( rev_timestamp ) FROM patchdemo_$wiki.revision ) AS last_edit @@ -66,10 +83,35 @@ } } +echo '
'; + uksort( $wikis, static function ( $a, $b ) use ( $wikis ) { return ( $wikis[ $b ][ 'ss_total_edits' ] ?? -1 ) <=> ( $wikis[ $a ][ 'ss_total_edits' ] ?? -1 ); } ); +echo new OOUI\FormLayout( [ + 'method' => 'POST', + 'items' => [ + new OOUI\FieldsetLayout( [ + 'label' => null, + 'items' => [ + new OOUI\FieldLayout( + new OOUI\ButtonInputWidget( [ + 'classes' => [ 'form-submit' ], + 'label' => 'Update stats', + 'type' => 'submit', + 'name' => 'update', + 'flags' => [ 'progressive' ] + ] ), + [ + 'align' => 'inline', + ] + ), + ] + ] ), + ] +] ); + echo ''; foreach ( $short_fields as $field => $fieldMeta ) { echo '';
Wiki' . $fieldMeta['label'] . '