Skip to content

Commit f5780b7

Browse files
authored
Blink taxonomy entry queries in term query builder (#124)
1 parent 9e690ef commit f5780b7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Taxonomies/TermQueryBuilder.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Support\Arr;
66
use Illuminate\Support\Str;
77
use Statamic\Contracts\Taxonomies\Term as TermContract;
8+
use Statamic\Facades\Blink;
89
use Statamic\Facades\Collection;
910
use Statamic\Facades\Entry;
1011
use Statamic\Facades\Site;
@@ -218,7 +219,14 @@ private function applyCollectionAndTaxonomyWheres()
218219
// or the ones associated with the collection
219220
// what we ultimately want is a subquery for terms in the form:
220221
// where('taxonomy', $taxonomy)->whereIn('slug', $slugArray)
221-
Entry::whereInCollection($this->collections)
222+
$collectionTaxonomyHash = md5(collect($this->collections)->merge(collect($taxonomies))->sort()->join('-'));
223+
224+
Blink::once("eloquent-taxonomy-hash-{$collectionTaxonomyHash}", function () use ($taxonomies) {
225+
return Entry::query()
226+
->whereIn('collection', $this->collections)
227+
->select($taxonomies)
228+
->get();
229+
})
222230
->flatMap(function ($entry) use ($taxonomies) {
223231
$slugs = [];
224232
foreach ($entry->collection()->taxonomies()->map->handle() as $taxonomy) {

0 commit comments

Comments
 (0)