2222use  Symfony \Component \Console \Input \InputInterface ;
2323use  Symfony \Component \Console \Input \InputOption ;
2424use  Symfony \Component \Console \Output \OutputInterface ;
25+ use  Graze \DogStatsD \Client  as  StatsDClient ;
2526
2627/** 
2728 * @author Jordi Boggiano <[email protected] > @@ -30,17 +31,15 @@ class DumpPackagesV2Command extends Command
3031{
3132    use  \App \Util \DoctrineTrait;
3233
33-     private  V2Dumper   $ dumper ;
34-     private  Locker   $ locker ;
35-     private  ManagerRegistry   $ doctrine ;
36-     private  string  $ cacheDir ;
37- 
38-     public  function  __construct (V2Dumper   $ dumper , Locker   $ locker , ManagerRegistry   $ doctrine , string  $ cacheDir , private  Logger   $ logger )
34+     public  function  __construct (
35+         private  V2Dumper   $ dumper ,
36+         private  Locker   $ locker ,
37+         private  ManagerRegistry   $ doctrine ,
38+         private  string  $ cacheDir ,
39+         private  Logger   $ logger ,
40+         private  StatsDClient   $ statsd ,
41+     )
3942    {
40-         $ this  ->dumper  = $ dumper ;
41-         $ this  ->locker  = $ locker ;
42-         $ this  ->doctrine  = $ doctrine ;
43-         $ this  ->cacheDir  = $ cacheDir ;
4443        parent ::__construct ();
4544    }
4645
@@ -105,6 +104,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
105104                    $ ids  = $ this  ->getEM ()->getConnection ()->fetchFirstColumn ('SELECT id FROM package WHERE frozen IS NULL ORDER BY id ASC ' );
106105                } else  {
107106                    $ ids  = $ this  ->getEM ()->getRepository (Package::class)->getStalePackagesForDumpingV2 ();
107+                     $ this  ->statsd ->gauge ('packagist.metadata_dump_queue ' , \count ($ ids ));
108+                     if  (\count ($ ids ) > 2000 ) {
109+                         $ this  ->logger ->emergency ('Huge backlog in packages to be dumped is abnormal ' , ['count '  => \count ($ ids )]);
110+                         $ ids  = array_slice ($ ids , 0 , 2000 );
111+                     }
108112                }
109113
110114                if  ($ ids  || $ force ) {
0 commit comments