Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-duplicate logic between REST API and URL Metrics post type #1867

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

$sample_size = od_get_url_metrics_breakpoint_sample_size();
for ( $j = 0; $j < $sample_size; $j++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$elements[0]['isLCP'] = false;
}

OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return static function ( Test_Embed_Optimizer_Optimization_Detective $test_case ): void {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

$sample_size = od_get_url_metrics_breakpoint_sample_size();
for ( $i = 0; $i < $sample_size; $i++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return static function ( Test_Embed_Optimizer_Optimization_Detective $test_case ): void {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static function () use ( $breakpoint_max_widths ) {

foreach ( $breakpoint_max_widths as $non_desktop_viewport_width ) {
for ( $i = 0; $i < $sample_size; $i++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -32,7 +32,7 @@ static function () use ( $breakpoint_max_widths ) {
}

for ( $i = 0; $i < $sample_size; $i++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static function () use ( $breakpoint_max_widths ) {
);

foreach ( $breakpoint_max_widths as $non_desktop_viewport_width ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$sample_size = od_get_url_metrics_breakpoint_sample_size();
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $viewport_width ) {
for ( $i = 0; $i < $sample_size; $i++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// Only populate the largest (desktop) viewport group.
for ( $i = 0; $i < $sample_size; $i++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static function () use ( $breakpoint_max_widths ) {
),
);
$elements[ $i ]['isLCP'] = true;
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return static function ( Test_Image_Prioritizer_Helper $test_case ): void {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -20,7 +20,7 @@
)
)
);
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static function () {
}
);

OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -25,7 +25,7 @@ static function () {
)
)
);
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -43,7 +43,7 @@ static function () {
)
)
);
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -61,7 +61,7 @@ static function () {
)
)
);
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static function () {
}
);

OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -25,7 +25,7 @@ static function () {
)
)
);
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -43,7 +43,7 @@ static function () {
)
)
);
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -61,7 +61,7 @@ static function () {
)
)
);
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static function () use ( $breakpoint_max_widths ) {
}
);

OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -24,7 +24,7 @@ static function () use ( $breakpoint_max_widths ) {
)
);

OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $viewport_width ) {
for ( $i = 0; $i < $sample_size; $i++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$slug = od_get_url_metrics_slug( od_get_normalized_query_vars() );

// Populate one URL Metric so that none of the IMG elements are unknown.
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static function () {
// Fully populate all viewport groups, but for all except desktop record that the LCP element had a different tag, id, or class.
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $i => $viewport_width ) {
for ( $j = 0; $j < $sample_size; $j++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static function () {
// Fully populate all viewport groups.
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $i => $viewport_width ) {
for ( $j = 0; $j < $sample_size; $j++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static function () {
// Partially populate all viewport groups.
foreach ( array_merge( od_get_breakpoint_max_widths(), array( 1000 ) ) as $i => $viewport_width ) {
for ( $j = 0; $j < $viewport_sample_sizes[ $i ]; $j++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand All @@ -48,7 +48,7 @@ static function () {
}

// Store one more URL metric for desktop which has a different background image.
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static function () use ( $breakpoint_max_widths ) {
);

foreach ( array_merge( $breakpoint_max_widths, array( 1000 ) ) as $viewport_width ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static function () use ( $breakpoint_max_widths ) {
);

foreach ( $breakpoint_max_widths as $non_desktop_viewport_width ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static function () {
// Populate the mobile and desktop viewport groups only.
foreach ( array( 400, 800 ) as $viewport_width ) {
for ( $i = 0; $i < $sample_size; $i++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static function () use ( $breakpoint_max_widths ) {
// Only populate the mobile and phablet viewport groups.
foreach ( array( 480, 600 ) as $viewport_width ) {
for ( $i = 0; $i < $sample_size; $i++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static function () use ( $mobile_breakpoint, $tablet_breakpoint ): array {

foreach ( $div_index_to_viewport_width_mapping as $div_index => $viewport_width ) {
for ( $i = 0; $i < $sample_size; $i++ ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
$slug,
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return static function ( Test_Image_Prioritizer_Helper $test_case ): void {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static function () use ( $breakpoint_max_widths ) {
);

foreach ( array_merge( $breakpoint_max_widths, array( 1000 ) ) as $viewport_width ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static function () use ( $breakpoint_max_widths ) {
);

foreach ( $breakpoint_max_widths as $non_desktop_viewport_width ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static function () use ( $breakpoint_max_widths ) {
);

foreach ( array_merge( $breakpoint_max_widths, array( 1000 ) ) as $viewport_width ) {
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static function () use ( $breakpoint_max_widths ) {
'xpath' => '/HTML/BODY/DIV[@id=\'page\']/*[2][self::VIDEO]',
),
);
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -31,7 +31,7 @@ static function () use ( $breakpoint_max_widths ) {
);
}

OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static function () use ( $breakpoint_max_widths ) {
}
);

OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down Expand Up @@ -39,7 +39,7 @@ static function () use ( $breakpoint_max_widths ) {
'xpath' => '/HTML/BODY/DIV[@id=\'page\']/*[2][self::VIDEO]',
),
);
OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand All @@ -50,7 +50,7 @@ static function () use ( $breakpoint_max_widths ) {
);
}

OD_URL_Metrics_Post_Type::store_url_metric(
$test_case->store_url_metric(
od_get_url_metrics_slug( od_get_normalized_query_vars() ),
$test_case->get_sample_url_metric(
array(
Expand Down
Loading