Skip to content

Commit 46dd912

Browse files
authored
Merge pull request #34 from humanmade/update-node-modules
Update npm packages
2 parents 19b91f0 + 461a17d commit 46dd912

File tree

6 files changed

+1126
-1237
lines changed

6 files changed

+1126
-1237
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": ["prettier"]
2+
"parser": "babel-eslint"
33
}

inc/namespace.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
namespace Altis\Analytics;
1010

11-
require_once ROOT_DIR . '/inc/utils.php';
12-
1311
function setup() {
1412
// Handle async scripts.
1513
add_filter( 'script_loader_tag', __NAMESPACE__ . '\\async_scripts', 20, 2 );
@@ -33,9 +31,9 @@ function get_client_side_data() : array {
3331
// Initialise data array.
3432
$data = [
3533
'Endpoint' => [],
36-
'AppPackageName' => sanitize_key( get_bloginfo('name') ),
34+
'AppPackageName' => sanitize_key( get_bloginfo( 'name' ) ),
3735
'AppVersion' => '',
38-
'SiteName' => get_bloginfo('name'),
36+
'SiteName' => get_bloginfo( 'name' ),
3937
'Attributes' => [],
4038
'Metrics' => [],
4139
];

inc/utils.php renamed to inc/utils/namespace.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,41 @@
1616
*/
1717
function composite_stddev( array $means, array $stddevs, array $group_counts ) : float {
1818
// Number of groups.
19-
$G = count( $means );
20-
if ( $G != count( $stddevs ) ) {
19+
$g = count( $means );
20+
if ( $g != count( $stddevs ) ) {
2121
trigger_error( 'inconsistent list lengths', E_USER_WARNING );
2222
return 0.0;
2323
}
24-
if ( $G != count( $group_counts ) ) {
24+
if ( $g != count( $group_counts ) ) {
2525
trigger_error( 'wrong nCounts list length', E_USER_WARNING );
2626
return 0.0;
2727
}
2828

2929
// Calculate total number of samples, N, and grand mean, GM.
30-
$N = array_sum( $group_counts ); // Total number of samples.
31-
if ( $N <= 1 ) {
32-
trigger_error( "Warning: only $N samples, SD is incalculable", E_USER_WARNING );
30+
$n = array_sum( $group_counts ); // Total number of samples.
31+
if ( $n <= 1 ) {
32+
trigger_error( "Warning: only $n samples, SD is incalculable", E_USER_WARNING );
3333
}
34-
$GM = 0.0;
35-
for ( $i = 0; $i < $G; $i++ ) {
36-
$GM += $means[ $i ] * $group_counts[ $i ];
34+
$gm = 0.0;
35+
for ( $i = 0; $i < $g; $i++ ) {
36+
$gm += $means[ $i ] * $group_counts[ $i ];
3737
}
38-
$GM /= $N; // Grand mean.
38+
$gm /= $n; // Grand mean.
3939

4040
// Calculate Error Sum of Squares.
41-
$ESS = 0.0;
42-
for ( $i = 0; $i < $G; $i++ ) {
43-
$ESS += ( pow( $stddevs[ $i ], 2 ) ) * ( $group_counts[ $i ] - 1 );
41+
$ess = 0.0;
42+
for ( $i = 0; $i < $g; $i++ ) {
43+
$ess += ( pow( $stddevs[ $i ], 2 ) ) * ( $group_counts[ $i ] - 1 );
4444
}
4545

4646
// Calculate Total Group Sum of Squares.
47-
$TGSS = 0.0;
48-
for ( $i = 0; $i < $G; $i++ ) {
49-
$TGSS += ( pow( $means[ $i ] - $GM, 2 ) ) * $group_counts[ $i ];
47+
$tgss = 0.0;
48+
for ( $i = 0; $i < $g; $i++ ) {
49+
$tgss += ( pow( $means[ $i ] - $gm, 2 ) ) * $group_counts[ $i ];
5050
}
5151

5252
// Calculate standard deviation as square root of grand variance.
53-
$result = sqrt( ( $ESS + $TGSS ) / ( $N - 1 ) );
53+
$result = sqrt( ( $ess + $tgss ) / ( $n - 1 ) );
5454
return $result;
5555
}
5656

@@ -98,7 +98,7 @@ function query( array $query, array $params = [] ) : ?array {
9898
if ( wp_remote_retrieve_response_code( $response ) !== 200 || is_wp_error( $response ) ) {
9999
if ( is_wp_error( $response ) ) {
100100
trigger_error( sprintf(
101-
"Analytics: elasticsearch query failed: %s",
101+
'Analytics: elasticsearch query failed: %s',
102102
$response->get_error_message()
103103
), E_USER_WARNING );
104104
} else {

0 commit comments

Comments
 (0)