Skip to content

Add Jetpack Monitor uptime in get site endpoint response #43999

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

Closed
wants to merge 4 commits into from
Closed
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
@@ -0,0 +1,4 @@
Significance: patch
Type: other

WordPress.com: Add Jetpack Monitor uptime in API response
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
'is_deleted' => '(bool) If the site flagged as deleted.',
'is_a4a_client' => '(bool) If the site is an A4A client site.',
'is_a4a_dev_site' => '(bool) If the site is an A4A dev site.',
'uptime' => '(array) An array keyed by unit of time that contains the site uptime for each day.',
);

/**
Expand Down Expand Up @@ -240,6 +241,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
'was_hosting_trial',
'was_upgraded_from_trial',
'is_a4a_dev_site',
'uptime',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed so that when the a request is made on WoA sites, the endpoint redecorates the response with these WPCOM values.

);

/**
Expand Down Expand Up @@ -626,6 +628,9 @@ protected function render_response_key( $key, &$response, $is_user_logged_in ) {
case 'is_a4a_dev_site':
$response[ $key ] = $this->site->is_a4a_dev_site();
break;
case 'uptime':
$response[ $key ] = $this->site->get_uptime();
break;
}

do_action( 'post_render_site_response_key', $key );
Expand Down
9 changes: 9 additions & 0 deletions projects/plugins/jetpack/sal/class.json-api-site-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,15 @@ public function is_a4a_dev_site() {
return false;
}

/**
* Returns the site update status for a given timeframe.
*
* @return array
*/
public function get_uptime() {
return null;
}

/**
* Return the user interactions with a site. Not used in Jetpack.
*
Expand Down
Loading