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

Fix graph filters #55

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
= 0.9.5 =
aristath marked this conversation as resolved.
Show resolved Hide resolved

Fixed:

* Post-type filters intruduced in v0.9.4 now also affect the graph results.

= 0.9.4 =

Enhancements:

* Added a setting to include post types, we default to `post` and `page` and you can add others as you wish.
jdevalk marked this conversation as resolved.
Show resolved Hide resolved

Fixed:

* Completing the last badge wouldn't ever work, fixed.
* Fixed some bugs around detecting badges being "had".
* Replaced links to the site with shortlinks, so we can change them as needed without doing a release.

= 0.9.3 =

Security:
Expand Down
33 changes: 25 additions & 8 deletions classes/widgets/class-published-content-density.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,27 @@
],
'count_callback' => [ $this, 'count_density' ],
'compound' => false,
'filter_results' => [ $this, 'filter_activities' ],
];
}

/**
* Callback to filter the activities.
*
* @param \Progress_Planner\Activities\Content[] $activities The activities array.
*
* @return \Progress_Planner\Activities\Content[]
*/
public function filter_activities( $activities ) {
return array_filter(
$activities,
function( $activity ) {

Check failure on line 98 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space after FUNCTION keyword; 0 found

Check failure on line 98 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space after FUNCTION keyword; 0 found
return \in_array( $activity->get_post()->post_type, Content_Helpers::get_post_types_names(), true );
}
);

}

Check failure on line 103 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Function closing brace must go on the next line following the body; found 1 blank lines before brace

Check failure on line 103 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Function closing brace must go on the next line following the body; found 1 blank lines before brace

/**
* Callback to count the words in the activities.
*
Expand Down Expand Up @@ -129,14 +147,13 @@
// Get the all-time average.
static $density;
if ( null === $density ) {
$density = $this->count_density(
\progress_planner()->get_query()->query_activities(
[
'category' => 'content',
'type' => 'publish',
]
)
);
$activities = $this->filter_activities( \progress_planner()->get_query()->query_activities(

Check failure on line 150 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Opening parenthesis of a multi-line function call must be the last content on the line

Check failure on line 150 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Opening parenthesis of a multi-line function call must be the last content on the line
[
'category' => 'content',
'type' => 'publish',
]
) );

Check failure on line 155 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Closing parenthesis of a multi-line function call must be on a line by itself

Check failure on line 155 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Closing parenthesis of a multi-line function call must be on a line by itself
$density = $this->count_density( $activities );

Check warning on line 156 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

Check warning on line 156 in classes/widgets/class-published-content-density.php

View workflow job for this annotation

GitHub Actions / Check code style

Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space
}
return $density;
}
Expand Down
18 changes: 18 additions & 0 deletions classes/widgets/class-published-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,38 @@
*/
public function get_chart_args() {
return [
'query_params' => [

Check warning on line 132 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Array double arrow not aligned correctly; expected 3 space(s) between "'query_params'" and double arrow, but found 1.

Check warning on line 132 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Array double arrow not aligned correctly; expected 3 space(s) between "'query_params'" and double arrow, but found 1.
'category' => 'content',
'type' => 'publish',
],
'dates_params' => [

Check warning on line 136 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Array double arrow not aligned correctly; expected 3 space(s) between "'dates_params'" and double arrow, but found 1.

Check warning on line 136 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Array double arrow not aligned correctly; expected 3 space(s) between "'dates_params'" and double arrow, but found 1.
'start' => \DateTime::createFromFormat( 'Y-m-d', \gmdate( 'Y-m-01' ) )->modify( $this->get_range() ),
'end' => new \DateTime(),
'frequency' => $this->get_frequency(),
'format' => 'M',
],
'chart_params' => [

Check warning on line 142 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Array double arrow not aligned correctly; expected 3 space(s) between "'chart_params'" and double arrow, but found 1.

Check warning on line 142 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Array double arrow not aligned correctly; expected 3 space(s) between "'chart_params'" and double arrow, but found 1.
'type' => 'line',
],
'compound' => false,

Check warning on line 145 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Array double arrow not aligned correctly; expected 7 space(s) between "'compound'" and double arrow, but found 5.

Check warning on line 145 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Array double arrow not aligned correctly; expected 7 space(s) between "'compound'" and double arrow, but found 5.
'filter_results' => [ $this, 'filter_activities' ],
];
}

/**
* Callback to filter the activities.
*
* @param \Progress_Planner\Activities\Content[] $activities The activities array.
*
* @return \Progress_Planner\Activities\Content[]
*/
public function filter_activities( $activities ) {
return array_filter(
$activities,
function( $activity ) {

Check failure on line 160 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space after FUNCTION keyword; 0 found

Check failure on line 160 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Expected 1 space after FUNCTION keyword; 0 found
return \in_array( $activity->get_post()->post_type, Content_Helpers::get_post_types_names(), true );
}
);

}

Check failure on line 165 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Function closing brace must go on the next line following the body; found 1 blank lines before brace

Check failure on line 165 in classes/widgets/class-published-content.php

View workflow job for this annotation

GitHub Actions / Check code style

Function closing brace must go on the next line following the body; found 1 blank lines before brace
}
6 changes: 6 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ https://youtu.be/e1bmxZYyXFY

== Upgrade Notice ==

= 0.9.5 =
aristath marked this conversation as resolved.
Show resolved Hide resolved

Fixed:

* Post-type filters intruduced in v0.9.4 now also affect the graph results.

= 0.9.4 =

Enhancements:
Expand Down
Loading