Skip to content

Add found_posts property to Timber\PostQuery#2074

Merged
jarednova merged 2 commits intomasterfrom
found-posts
Oct 1, 2019
Merged

Add found_posts property to Timber\PostQuery#2074
jarednova merged 2 commits intomasterfrom
found-posts

Conversation

@gchtr
Copy link
Copy Markdown
Member

@gchtr gchtr commented Sep 26, 2019

Ticket: #1973, #1257

Issue

There is no easy way to access the amount of found posts in a query.

Solution

Add found_posts property to Timber\PostQuery. It will only be filled if Timber\PostQuery uses Timber\QueryIterator internally, but not when what you pass to Timber\PostQuery is already a collection of posts.

Impact

Happyness.

Usage Changes

You can now access the amount of found posts through the found_posts property in Timber\PostQuery:

$query = new Timber\PostQuery( [
    'post_type' => 'post',
] );

$query->found_posts;

Considerations

Are there other properties that should be easy to access?

Testing

Yes. Including tests for special cases when no_found_rows is used in the query.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 26, 2019

Codecov Report

Merging #2074 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2074      +/-   ##
============================================
+ Coverage     95.01%   95.02%   +<.01%     
- Complexity     1572     1574       +2     
============================================
  Files            49       49              
  Lines          3714     3718       +4     
============================================
+ Hits           3529     3533       +4     
  Misses          185      185
Impacted Files Coverage Δ Complexity Δ
lib/PostQuery.php 100% <100%> (ø) 6 <0> (+1) ⬆️
lib/QueryIterator.php 93.58% <100%> (+0.16%) 46 <1> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2afafb...dfcee41. Read the comment docs.

@jarednova
Copy link
Copy Markdown
Member

Let's see, we got

  1. Clean code
  2. Tests
  3. Release notes for the readme

... yeah, I want to do something to feel useful — but I think it's all taken care of by @gchtr. Merging!

@jarednova jarednova merged commit 0d50f7b into master Oct 1, 2019
@gchtr gchtr mentioned this pull request Oct 6, 2019
24 tasks
@gchtr gchtr deleted the found-posts branch April 26, 2020 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants