catalog: introduce CatalogStats to retrieve all the stats of the catalog
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 15 Aug 2017 20:24:50 +0000 (16:24 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 26 Sep 2017 15:10:05 +0000 (11:10 -0400)
Useful for serialization

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/catalog.nit

index d8c42b2..46aeb1b 100644 (file)
@@ -544,6 +544,48 @@ class Catalog
                mpackages_stats[mpackage] = stats
                return stats
        end
+
+       # Compose catalog stats
+       var catalog_stats: CatalogStats is lazy do
+               var stats = new CatalogStats
+               stats.packages = mpackages.length
+               stats.maintainers = maint2proj.length
+               stats.contributors = contrib2proj.length
+               stats.tags = tag2proj.length
+               stats.modules = mmodules.sum
+               stats.classes = mclasses.sum
+               stats.methods = mmethods.sum
+               stats.loc = loc.sum
+               return stats
+       end
+end
+
+# Catalog statistics
+class CatalogStats
+
+       # Number of packages
+       var packages = 0
+
+       # Number of maintainers
+       var maintainers = 0
+
+       # Number of contributors
+       var contributors = 0
+
+       # Number of tags
+       var tags = 0
+
+       # Number of modules
+       var modules = 0
+
+       # Number of classes
+       var classes = 0
+
+       # Number of methods
+       var methods = 0
+
+       # Number of line of codes
+       var loc = 0
 end
 
 # MPackage statistics for the catalog