@@ -335,6 +335,10 @@ protected function countForFunctions(Database $dbForProject, string $region)
335335 $ this ->createStatsDocuments ($ region , str_replace ("{resourceType} " , RESOURCE_TYPE_FUNCTIONS , METRIC_RESOURCE_TYPE_DEPLOYMENTS ), $ deployments );
336336 $ this ->createStatsDocuments ($ region , str_replace ("{resourceType} " , RESOURCE_TYPE_FUNCTIONS , METRIC_RESOURCE_TYPE_BUILDS ), $ deployments );
337337
338+
339+ // count runtimes
340+ $ runtimes = [];
341+
338342 $ this ->foreachDocument ($ dbForProject , 'functions ' , [], function (Document $ function ) use ($ dbForProject , $ region ) {
339343 $ functionDeploymentsStorage = $ dbForProject ->sum ('deployments ' , 'sourceSize ' , [
340344 Query::equal ('resourceInternalId ' , [$ function ->getSequence ()]),
@@ -364,7 +368,19 @@ protected function countForFunctions(Database $dbForProject, string $region)
364368 });
365369
366370 $ this ->createStatsDocuments ($ region , str_replace (['{resourceType} ' ,'{resourceInternalId} ' ], [RESOURCE_TYPE_FUNCTIONS ,$ function ->getSequence ()], METRIC_RESOURCE_TYPE_ID_BUILDS_STORAGE ), $ functionBuildsStorage );
371+
372+ // Runtimes count
373+ $ runtime = $ function ->getAttribute ('runtime ' );
374+ if (!empty ($ runtime )) {
375+ $ runtimes [$ runtime ] = ($ runtimes [$ runtime ] ?? 0 ) + 1 ;
376+ }
367377 });
378+
379+ // Write runtimes counts
380+ foreach ($ runtimes as $ runtime => $ count ) {
381+ $ this ->createStatsDocuments ($ region , str_replace ('{runtime} ' , $ runtime , METRIC_FUNCTIONS_RUNTIME ), $ count );
382+ }
383+
368384 }
369385
370386 protected function countForSites (Database $ dbForProject , string $ region )
@@ -385,6 +401,9 @@ protected function countForSites(Database $dbForProject, string $region)
385401 $ this ->createStatsDocuments ($ region , str_replace ("{resourceType} " , RESOURCE_TYPE_SITES , METRIC_RESOURCE_TYPE_DEPLOYMENTS ), $ deployments );
386402 $ this ->createStatsDocuments ($ region , str_replace ("{resourceType} " , RESOURCE_TYPE_SITES , METRIC_RESOURCE_TYPE_BUILDS ), $ deployments );
387403
404+ // Count frameworks
405+ $ frameworks = [];
406+
388407 $ this ->foreachDocument ($ dbForProject , 'sites ' , [], function (Document $ site ) use ($ dbForProject , $ region ) {
389408 $ siteDeploymentsStorage = $ dbForProject ->sum ('deployments ' , 'sourceSize ' , [
390409 Query::equal ('resourceInternalId ' , [$ site ->getSequence ()]),
@@ -410,7 +429,18 @@ protected function countForSites(Database $dbForProject, string $region)
410429 ]);
411430
412431 $ this ->createStatsDocuments ($ region , str_replace (['{resourceType} ' ,'{resourceInternalId} ' ], [RESOURCE_TYPE_SITES ,$ site ->getSequence ()], METRIC_RESOURCE_TYPE_ID_BUILDS_STORAGE ), $ siteBuildsStorage );
432+
433+ // Frameworks count
434+ $ framework = $ site ->getAttribute ('framework ' );
435+ if (!empty ($ framework )) {
436+ $ frameworks [$ framework ] = ($ frameworks [$ framework ] ?? 0 ) + 1 ;
437+ }
413438 });
439+
440+ // Write frameworks counts
441+ foreach ($ frameworks as $ framework => $ count ) {
442+ $ this ->createStatsDocuments ($ region , str_replace ('{framework} ' , $ framework , METRIC_SITES_FRAMEWORK ), $ count );
443+ }
414444 }
415445
416446 protected function createStatsDocuments (string $ region , string $ metric , int $ value )
0 commit comments