77
88namespace OC \Core \Command \Profiler ;
99
10+ use _HumbugBox1cb33d1f20f1 \LanguageServerProtocol \PackageDescriptor ;
1011use OC \Core \Command \Base ;
1112use OCP \Profiler \IProfiler ;
1213use Symfony \Component \Console \Input \InputInterface ;
@@ -25,23 +26,30 @@ protected function configure() {
2526 $ this
2627 ->setName ('profiler:export ' )
2728 ->setDescription ('Export captured profiles as json ' )
28- ->addOption ('limit ' , null , InputOption::VALUE_REQUIRED , 'Maximum number of profiles to return ' )
29- ->addOption ('url ' , null , InputOption::VALUE_REQUIRED , 'Url to list profiles for ' )
30- ->addOption ('since ' , null , InputOption::VALUE_REQUIRED , 'Minimum date for listed profiles, as unix timestamp ' )
31- ->addOption ('before ' , null , InputOption::VALUE_REQUIRED , 'Maximum date for listed profiles, as unix timestamp ' );
29+ ->addOption ('limit ' , null , InputOption::VALUE_REQUIRED , 'Maximum number of profiles to export ' )
30+ ->addOption ('url ' , null , InputOption::VALUE_REQUIRED , 'Url to export profiles for ' )
31+ ->addOption ('since ' , null , InputOption::VALUE_REQUIRED , 'Minimum date for exported profiles, as unix timestamp ' )
32+ ->addOption ('before ' , null , InputOption::VALUE_REQUIRED , 'Maximum date for exported profiles, as unix timestamp ' )
33+ ->addOption ('token ' , null , InputOption::VALUE_REQUIRED , 'Export only profile for a single request token ' );
3234 }
3335
3436 protected function execute (InputInterface $ input , OutputInterface $ output ): int {
3537 $ since = $ input ->getOption ('since ' ) ? (int )$ input ->getOption ('since ' ) : null ;
3638 $ before = $ input ->getOption ('before ' ) ? (int )$ input ->getOption ('before ' ) : null ;
3739 $ limit = $ input ->getOption ('limit ' ) ? (int )$ input ->getOption ('limit ' ) : 1000 ;
40+ $ token = $ input ->getOption ('token ' ) ? $ input ->getOption ('token ' ) : null ;
3841 $ url = $ input ->getOption ('url ' );
3942
40- $ profiles = $ this ->profiler ->find ($ url , $ limit , null , $ since , $ before );
41- $ profiles = array_reverse ($ profiles );
42- $ profiles = array_map (function (array $ profile ) {
43- return $ this ->profiler ->loadProfile ($ profile ['token ' ]);
44- }, $ profiles );
43+ if ($ token ) {
44+ $ profiles = [$ this ->profiler ->loadProfile ($ token )];
45+ $ profiles = array_filter ($ profiles );
46+ } else {
47+ $ profiles = $ this ->profiler ->find ($ url , $ limit , null , $ since , $ before );
48+ $ profiles = array_reverse ($ profiles );
49+ $ profiles = array_map (function (array $ profile ) {
50+ return $ this ->profiler ->loadProfile ($ profile ['token ' ]);
51+ }, $ profiles );
52+ }
4553
4654 $ output ->writeln (json_encode ($ profiles ));
4755
0 commit comments