1010use kriskbx \gtt \MergeRequest ;
1111use kriskbx \gtt \Output \TableOutput ;
1212use kriskbx \gtt \Project ;
13+ use kriskbx \gtt \Time ;
1314use Symfony \Component \Console \Helper \ProgressBar ;
1415use Symfony \Component \Console \Input \InputArgument ;
1516use Symfony \Component \Console \Input \InputInterface ;
@@ -72,7 +73,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
7273 $ includeLabels ,
7374 $ excludeLabels ,
7475 $ includeByLabels ,
75- $ excludeByLabels
76+ $ excludeByLabels ,
77+ $ timeFormat
7678 ) = $ this ->getConfiguration ($ input );
7779
7880 // Get project
@@ -106,7 +108,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
106108 }
107109
108110 // Set time records in issues
109- $ issues = $ this ->setTimesInIssues ($ output , $ issues , $ from , $ to , $ user );
111+ $ issues = $ this ->setTimesInIssues ($ output , $ issues , $ from , $ to , $ user , $ this ->config ['hoursPerDay ' ],
112+ $ timeFormat );
110113// $mergeRequests = $this->setTimesInIssues($output, $mergeRequests, $from, $to, $user);
111114
112115 // Put everything out there!
@@ -250,22 +253,30 @@ protected function getMergeRequests(
250253 *
251254 * @param OutputInterface $output
252255 * @param Collection $issues
253- * @param string $user
254256 * @param Carbon $from
255257 * @param Carbon $to
256258 *
257- * @return Collection
259+ * @param string $user
260+ * @param int $hoursPerDay
261+ * @param string $timeFormat
258262 *
259- * @throws \Exception
263+ * @return Collection
260264 */
261- protected function setTimesInIssues (OutputInterface $ output , Collection $ issues , Carbon $ from , Carbon $ to , $ user )
262- {
265+ protected function setTimesInIssues (
266+ OutputInterface $ output ,
267+ Collection $ issues ,
268+ Carbon $ from ,
269+ Carbon $ to ,
270+ $ user ,
271+ $ hoursPerDay = 8 ,
272+ $ timeFormat = Time::TIME_FORMAT
273+ ) {
263274 $ progress = new ProgressBar ($ output , $ issues ->count ());
264275 $ progress ->setFormat ('* Processing issues... %current%/%max% [%bar%] %percent:3s%% | <fg=green>%remaining%</> ' );
265276
266277 // Add times to each Issue
267- $ issues = $ issues ->map (function (Issue $ issue ) use ($ from , $ to , $ user , &$ progress ) {
268- $ issue ->setTimes ($ from , $ to , $ user );
278+ $ issues = $ issues ->map (function (Issue $ issue ) use ($ from , $ to , $ user , &$ progress, $ hoursPerDay , $ timeFormat ) {
279+ $ issue ->setTimes ($ from , $ to , $ user, $ hoursPerDay , $ timeFormat );
269280
270281 $ progress ->advance ();
271282
@@ -305,6 +316,7 @@ protected function getConfiguration(InputInterface $input)
305316 $ excludeLabels = $ input ->getOption ('exclude_labels ' ) === null ? $ this ->config ['excludeLabels ' ] : $ input ->getOption ('exclude_labels ' );
306317 $ includeByLabels = $ input ->getOption ('include_by_labels ' ) === null ? $ this ->config ['includeByLabels ' ] : $ input ->getOption ('include_by_labels ' );
307318 $ excludeByLabels = $ input ->getOption ('exclude_by_labels ' ) === null ? $ this ->config ['excludeByLabels ' ] : $ input ->getOption ('exclude_by_labels ' );
319+ $ timeFormat = $ this ->config ['timeFormat ' ] = $ input ->getOption ('time_format ' ) === null ? $ this ->config ['timeFormat ' ] : $ input ->getOption ('time_format ' );
308320
309321 return [
310322 $ from ,
@@ -320,7 +332,8 @@ protected function getConfiguration(InputInterface $input)
320332 $ includeLabels ,
321333 $ excludeLabels ,
322334 $ includeByLabels ,
323- $ excludeByLabels
335+ $ excludeByLabels ,
336+ $ timeFormat
324337 ];
325338 }
326339
0 commit comments