3939use DateTimeImmutable ;
4040use DateTimeInterface ;
4141use DBmysql ;
42- use GlpiPlugin \ Carbon \ Zone ;
42+ use DBmysqlIterator ;
4343use GlpiPlugin \Carbon \CarbonEmission ;
4444use GlpiPlugin \Carbon \DataTracking \TrackedFloat ;
4545use GlpiPlugin \Carbon \Engine \V1 \EngineInterface ;
@@ -114,11 +114,12 @@ public function setLimit(int $limit)
114114 }
115115
116116 /**
117- * Start the historization of all items
117+ * Get an iterator of items to evaluate
118118 *
119- * @return int count of entries generated
119+ * @param array $crit criterias
120+ * @return DBmysqlIterator
120121 */
121- public function evaluateItems ( ): int
122+ public function getItemsToEvaluate ( array $ crit = [] ): DBmysqlIterator
122123 {
123124 /** @var DBmysql $DB */
124125 global $ DB ;
@@ -130,10 +131,20 @@ public function evaluateItems(): int
130131 if (!is_subclass_of ($ itemtype , CommonDBTM::class)) {
131132 throw new \LogicException ('Itemtype does not inherits from ' . CommonDBTM::class);
132133 }
134+ $ iterator = $ DB ->request ($ this ->getEvaluableQuery ([], false ));
133135
134- $ count = 0 ;
136+ return $ iterator ;
137+ }
135138
136- $ iterator = $ DB ->request ($ this ->getEvaluableQuery ([], false ));
139+ /**
140+ * Start the historization of all items
141+ *
142+ * @return int count of entries generated
143+ */
144+ public function evaluateItems (DBmysqlIterator $ iterator ): int
145+ {
146+ /** @var int $count count of successfully evaluated assets */
147+ $ count = 0 ;
137148 foreach ($ iterator as $ row ) {
138149 $ count += $ this ->evaluateItem ($ row ['id ' ]);
139150 if ($ this ->limit_reached ) {
0 commit comments