Skip to content

Commit e2380cf

Browse files
authored
Merge pull request #390 from ProgressPlanner/filip/rest-stats-new-emails
Tweak for Rest API Stats endpoint
2 parents 93480f4 + bbc60aa commit e2380cf

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

classes/class-rest-api-stats.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,23 +157,15 @@ public function get_stats( \WP_REST_Request $request ) {
157157
// Timezone offset.
158158
$data['timezone_offset'] = \wp_timezone()->getOffset( new \DateTime( 'midnight' ) ) / 3600;
159159

160-
$todo_items = \progress_planner()->get_todo()->get_items();
161-
$pending_todo_items = [];
162-
foreach ( $todo_items as $item ) {
163-
if ( ! isset( $item['status'] ) || 'completed' !== $item['status'] ) {
164-
$pending_todo_items[] = $item['title'];
165-
}
166-
}
167-
$data['todo'] = $pending_todo_items;
168-
169160
// Pending tasks include remote tasks.
170161
$ravis_recommendations = \progress_planner()->get_suggested_tasks()->get_pending_tasks_with_details();
171162
$data['recommendations'] = [];
172163
foreach ( $ravis_recommendations as $recommendation ) {
173164
$data['recommendations'][] = [
174-
'id' => $recommendation['task_id'],
175-
'title' => $recommendation['title'],
176-
'url' => isset( $recommendation['url'] ) ? $recommendation['url'] : '',
165+
'id' => $recommendation['task_id'],
166+
'title' => $recommendation['title'],
167+
'url' => isset( $recommendation['url'] ) ? $recommendation['url'] : '',
168+
'provider_id' => $recommendation['provider_id'],
177169
];
178170
}
179171

tests/phpunit/test-class-api-get-stats.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function testEndpoint() {
144144
'scores',
145145
'website',
146146
'timezone_offset',
147-
'todo',
147+
'recommendations',
148148
'plugin_url',
149149
];
150150

0 commit comments

Comments
 (0)