15 private const LIMIT = 500;
22 private array $storage = [];
24 private array $option;
28 $this->option = &$option;
32 if ($this->groups->isEmpty())
34 return self::FINISH_EXECUTION;
41 return self::CONTINUE_EXECUTION;
44 private function fetchGroups(): void
46 $query = WorkgroupTable::query()
47 ->setSelect([
'ID',
'PROJECT',
'SCRUM_MASTER_ID',
'TYPE'])
49 ->where(
'ID',
'>', $this->getLastId())
50 ->setOrder([
'ID' =>
'ASC'])
51 ->setLimit(self::LIMIT);
53 $this->groups =
$query->exec()->fetchCollection();
56 private function convert(): void
58 foreach ($this->groups as $group)
60 $this->setType($group);
64 private function save(): void
66 foreach ($this->storage as $collection)
68 $collection->save(
true);
72 private function setType(GroupEntity $group): void
74 $typeBefore = $group->getType();
76 if ($typeBefore === Type::Collab->value)
81 if ($group->getScrumMasterId() > 0 && $group->getProject())
83 $group->setType(Type::Scrum->value);
85 elseif ($group->getProject())
87 $group->setType(Type::Project->value);
91 $group->setType(Type::getDefault()->value);
94 if ($typeBefore !== $group->getType())
100 private function store(GroupEntity $group): void
102 if (!isset($this->storage[$group->getType()]))
104 $this->storage[$group->getType()] =
new GroupEntityCollection();
107 $this->storage[$group->getType()]->add($group);
110 private function getLastId(): int
112 return (
int)($this->option[
'lastId'] ?? 0);
115 private function setLastId(): void
117 $this->option[
'lastId'] = max($this->groups->getIdList());
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)