Skip to content

Commit

Permalink
Use query builder to prevent timeout (#347)
Browse files Browse the repository at this point in the history
* Use query builder

Prevent timeout in query when there's many entries

* Use `offset`/`limit` methods instead

The `skip`/`take` methods aren't available on the Stache query builder.

---------

Co-authored-by: Duncan McClean <[email protected]>
  • Loading branch information
sylvesterdamgaard and duncanmcclean authored Sep 10, 2024
1 parent bc143f9 commit 08778ad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Sitemap/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function paginatedPages(int $page)
$entryCount = $sitemap->publishedEntriesCount() - 1;

if ($offset < $entryCount) {
$entries = $sitemap->publishedEntries()->skip($offset)->take($perPage);
$entries = $sitemap->publishedEntriesQuery()->offset($offset)->limit($perPage)->get();

if ($entries->count() < $remaining) {
$remaining -= $entries->count();
Expand Down

0 comments on commit 08778ad

Please sign in to comment.