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 3 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
20 changes: 19 additions & 1 deletion classes/widgets/class-published-content-density.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,26 @@ public function get_chart_args() {
],
'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 ) {
return \in_array( $activity->get_post()->post_type, Content_Helpers::get_post_types_names(), true );
}
);
}

/**
* Callback to count the words in the activities.
*
Expand Down Expand Up @@ -129,14 +146,15 @@ public function get_all_activities_density() {
// Get the all-time average.
static $density;
if ( null === $density ) {
$density = $this->count_density(
$activities = $this->filter_activities(
\progress_planner()->get_query()->query_activities(
jdevalk marked this conversation as resolved.
Show resolved Hide resolved
[
'category' => 'content',
'type' => 'publish',
]
)
);
$density = $this->count_density( $activities );
}
return $density;
}
Expand Down
25 changes: 21 additions & 4 deletions classes/widgets/class-published-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,37 @@ public function get_stats() {
*/
public function get_chart_args() {
return [
'query_params' => [
'query_params' => [
'category' => 'content',
'type' => 'publish',
],
'dates_params' => [
'dates_params' => [
'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' => [
'chart_params' => [
'type' => 'line',
],
'compound' => false,
'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 ) {
return \in_array( $activity->get_post()->post_type, Content_Helpers::get_post_types_names(), true );
}
);
}
}
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