statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 71 forks source link

make use of $ids in updateEntryOrder method #301

Closed mkwia closed 2 weeks ago

mkwia commented 2 weeks ago

This PR optimises the collection query in the updateEntryOrder method by making use of ids which are redundant in the current method.

On some of our sites this caused a large number of jobs to be dispatched to the queue when entries were reordered in collection trees. This fix has resolved our issue when applied via composer patch.

The fix is akin to logic already in use in the updateEntryUris method

ryanmitchell commented 2 weeks ago

Wonderful, thank you. I've changed it slightly to use ->when as it reads better (to me).

clementmas commented 2 weeks ago

I'm getting errors from this PR: Undefined variable $query.

I think this should be ->when($ids, fn ($query) => $query->whereIn('id', $ids))

ryanmitchell commented 2 weeks ago

@clementmas thanks - fixed in v4.3.1