If you only run the job once a day, then using formula or a hook would not have any impact in terms of server usage.
Ultimately the best solution is the one that works for each one of us


<?php
namespace Espo\Custom\Jobs;
use Espo\Core\ORM\EntityManager;
use Espo\Core\Job\JobDataLess;
class UpdateDwellTime implements JobDataLess
{
protected $entityManager;
protected $dwellTime = 0;
public function __construct(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
}
public function run(): void
{
$list = $this->entityManager
->getRDBRepository('Claim')
->where([
'stage!=' => ['Invoice Settled', 'Failed Processing']
])
->find();
foreach ($list as $e) {
$e->set('dwellTime', $this->increment());
$this->entityManager->saveEntity($e);
}
}
public function increment() {
return $dwellTime = $dwellTime + 1;
}
}
Leave a comment: