trigger column (cross-cutting) + move-mode; move relocates instead of copies (v1.9)
This commit is contained in:
@@ -145,6 +145,49 @@ class RecoRecoModel extends Base
|
||||
// counter is FinanceBuddy's live installment_current instead.
|
||||
$count = isset($meta['recoreco_count']) && ctype_digit((string) $meta['recoreco_count']) ? (int) $meta['recoreco_count'] : 1;
|
||||
|
||||
// Trigger gate (cross-cutting, both modes): fire only while the card is in a triggering column,
|
||||
// and never while it sits in the target (Gate 2, uniform).
|
||||
$col = (int) $task['column_id'];
|
||||
$trig = isset($meta['recoreco_trigger_column']) ? $meta['recoreco_trigger_column'] : 'any';
|
||||
$invert = isset($meta['recoreco_trigger_invert']) && $meta['recoreco_trigger_invert'] == 1;
|
||||
$base = ($trig === 'any') ? true : ($invert ? ($col !== (int) $trig) : ($col === (int) $trig));
|
||||
|
||||
if (! ($base && $col !== $targetColumn)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Move-mode: relocate the single card to the target instead of spawning a clone. No back-fill,
|
||||
// no clone metadata. Honors the standalone limit (save() forced follow=0, so $limit is it).
|
||||
if (isset($meta['recoreco_move']) && $meta['recoreco_move'] == 1) {
|
||||
$cursor = (int) $task['date_due'];
|
||||
|
||||
if ($cursor - $daysBefore * 86400 >= $horizon) {
|
||||
return 0; // not due yet
|
||||
}
|
||||
|
||||
if ($limit > 0 && $count > $limit) {
|
||||
$this->completePlan($task, $task_id); // safety: re-armed after completion
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->taskPositionModel->movePosition($task['project_id'], $task_id, $targetColumn, 1, $task['swimlane_id'], false);
|
||||
|
||||
$next = $this->calculator()->occurrenceFrom($anchor, $frequency, $lastDay, $cursor, false);
|
||||
if ($next !== null && $next > $cursor) {
|
||||
$this->setDue($task_id, $next); // advance one period
|
||||
}
|
||||
|
||||
if ($limit > 0) {
|
||||
$count++;
|
||||
$this->setCount($task_id, $count);
|
||||
if ($count > $limit) {
|
||||
$this->completePlan($task, $task_id);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Phase 1 -- walk forward from the cursor, collecting every occurrence whose fire time has
|
||||
// arrived. The loop exits on the first occurrence still ahead of the horizon, which is then
|
||||
// the "next future" one to park on.
|
||||
|
||||
Reference in New Issue
Block a user