Skip to content

Commit

Permalink
UHF-8819: Remove old listings that do not have all the required fields
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrsky committed Dec 27, 2023
1 parent 81dd3c8 commit 91c96e6
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,25 @@ private function isJobListingInHelbit(FieldableEntityInterface $jobListing): boo
* Job listings entity ids.
*/
private function findExpiredJobListings(): array {
return $this->storage
$query = $this->storage
->getQuery()
->accessCheck(FALSE)
->condition('type', 'job_listing')
// Only consider unpublished.
->condition('status', 0)
// Only entities that have been unpublished before the threshold.
->condition('status', 0);

$legacy = $query->andConditionGroup()
// Delete legacy listings that do not have all the required fields.
->condition('field_publication_ends', NULL, 'IS NULL')
->condition('changed', strtotime('-1 year'), '<');

$thresholdOrLegacy = $query->orConditionGroup()
// Entities that have been unpublished before the threshold.
->condition('field_publication_ends', $this->getExpiredThreshold(), '<')
->condition($legacy);

return $query
->condition($thresholdOrLegacy)
->range(0, JobListingCleaner::BATCH_SIZE)
->sort('field_publication_ends', 'ASC')
->execute();
Expand Down

0 comments on commit 91c96e6

Please sign in to comment.