View more context

 

rista

it might help but it need some additional parsing 🙂

dorsetdigital

Are you doing these checks in the CMS? Are you aware of the isChanged() methods?

rista

and yes I'm aware of isChanged and getChangedFields but I need some additional information

rista

and also I need to update that instance in order to check if it's changed

Jay
  1. if (isset($searchParams['DraftOnly'])) {
  2. // get draft only records
  3. $stage = Versioned::get_by_stage(Items::class, Versioned::DRAFT)->column('ID');
  4. $live = Versioned::get_by_stage(Items::class, Versioned::LIVE)->column('ID');
  5.  
  6. $ids = array_diff($stage, $live);
  7. if (empty($ids)) {
  8. $query->filter('ID', 0);
  9. } else {
  10. $query->filter('ID', $ids);
  11. }
  12. }

Guys I am having a final issue with my search problem. These DataObject (Items) has over 200,000 results and I am trying to fetch just the draft versions but this is proving to timeout. Is there a better solution to getting just the Draft items?

Conan
Conan in #cms4 2019-11-29 11:19:24 (edited) (deleted)

You could also first just query the $liveIds and then exclude the IDs.

  1. $stage = Versioned::get_by_stage(Items::class, Versioned::DRAFT)->exlude('ID', $liveIds); // <- check that $liveIds is not empty, SS4 does not filter on empty sets.