Skip to content
This repository was archived by the owner on Sep 23, 2023. It is now read-only.

Commit ca2ffd0

Browse files
committed
editcounts: Add button to update site stats
1 parent 0a6be04 commit ca2ffd0

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

editcounts.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,27 @@
5151
if ( !$results ) {
5252
die( $mysqli->error );
5353
}
54+
55+
$update = isset( $_POST['update'] );
56+
57+
echo '<div class="consoleLog">';
58+
5459
$wikis = [];
5560
while ( $data = $results->fetch_assoc() ) {
5661
$wiki = $data['wiki'];
5762
$wikis[$wiki] = $data;
63+
64+
if ( $update ) {
65+
$cmd = make_shell_command(
66+
[
67+
'PATCHDEMO' => __DIR__,
68+
'NAME' => $wiki,
69+
],
70+
'sh -c \'php $PATCHDEMO/wikis/$NAME/w/maintenance/initSiteStats.php --update --active\''
71+
);
72+
shell_echo( $cmd );
73+
}
74+
5875
$stats = $mysqli->query( "
5976
SELECT *,
6077
( SELECT MAX( rev_timestamp ) FROM patchdemo_$wiki.revision ) AS last_edit
@@ -66,10 +83,35 @@
6683
}
6784
}
6885

86+
echo '</div>';
87+
6988
uksort( $wikis, static function ( $a, $b ) use ( $wikis ) {
7089
return ( $wikis[ $b ][ 'ss_total_edits' ] ?? -1 ) <=> ( $wikis[ $a ][ 'ss_total_edits' ] ?? -1 );
7190
} );
7291

92+
echo new OOUI\FormLayout( [
93+
'method' => 'POST',
94+
'items' => [
95+
new OOUI\FieldsetLayout( [
96+
'label' => null,
97+
'items' => [
98+
new OOUI\FieldLayout(
99+
new OOUI\ButtonInputWidget( [
100+
'classes' => [ 'form-submit' ],
101+
'label' => 'Update stats',
102+
'type' => 'submit',
103+
'name' => 'update',
104+
'flags' => [ 'progressive' ]
105+
] ),
106+
[
107+
'align' => 'inline',
108+
]
109+
),
110+
]
111+
] ),
112+
]
113+
] );
114+
73115
echo '<table class="wikis"><tr class="headerRow"><th>Wiki</th>';
74116
foreach ( $short_fields as $field => $fieldMeta ) {
75117
echo '<th>' . $fieldMeta['label'] . '</th>';

0 commit comments

Comments
 (0)