chiark / gitweb /
Added license and vcs type analysis to stats
authorCiaran Gultnieks <ciaran@ciarang.com>
Sun, 8 Apr 2012 13:07:01 +0000 (14:07 +0100)
committerCiaran Gultnieks <ciaran@ciarang.com>
Sun, 8 Apr 2012 13:07:01 +0000 (14:07 +0100)
fdroidserver/stats.py

index 5492096e56a8c77d4e1d95b8cda50723e08f7c30..e191f538b46cf73413067791c40f7d4ff3b74d0a 100644 (file)
@@ -43,6 +43,8 @@ def main():
                       help="Download logs we don't have")
     (options, args) = parser.parse_args()
 
+    # Get all metadata-defined apps...
+    metaapps = common.read_metadata(options.verbose)
 
     statsdir = 'stats'
     logsdir = os.path.join(statsdir, 'logs')
@@ -123,18 +125,49 @@ def main():
                             unknownapks.append(apkname)
 
     # Calculate and write stats for total downloads...
-    f = open('stats/total_downloads_app.txt', 'w')
     lst = []
     alldownloads = 0
     for app, count in apps.iteritems():
         lst.append(app + " " + str(count))
         alldownloads += count
     lst.append("ALL " + str(alldownloads))
+    f = open('stats/total_downloads_app.txt', 'w')
     f.write('# Total downloads by application, since October 2011\n')
     for line in sorted(lst):
         f.write(line + '\n')
     f.close()
 
+    # Calculate and write stats for repo types...
+    repotypes = {}
+    for app in metaapps:
+        if len(app['Repo Type']) == 0:
+            rtype = 'none'
+        else:
+            rtype = app['Repo Type']
+        if rtype in repotypes:
+            repotypes[rtype] += 1;
+        else:
+            repotypes[rtype] = 1
+    f = open('stats/repotypes.txt', 'w')
+    for rtype, count in repotypes.iteritems():
+        f.write(rtype + ' ' + str(count) + '\n')
+    f.close()
+
+    # Calculate and write stats for licenses...
+    licenses = {}
+    for app in metaapps:
+        license = app['License']
+        if license in licenses:
+            licenses[license] += 1;
+        else:
+            licenses[license] = 1
+    f = open('stats/licenses.txt', 'w')
+    for license, count in licenses.iteritems():
+        f.write(license + ' ' + str(count) + '\n')
+    f.close()
+
+
+
     # Write list of latest apps added to the repo...
     latest = knownapks.getlatest(10)
     f = open('stats/latestapps.txt', 'w')