mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-10 01:10:11 +01:00
stats.py: Create downloads stats for app and version
This commit is contained in:
parent
d1ad5bd74e
commit
fd28c0dca5
@ -115,6 +115,7 @@ def main():
|
|||||||
if options.verbose:
|
if options.verbose:
|
||||||
print 'Processing logs...'
|
print 'Processing logs...'
|
||||||
apps = {}
|
apps = {}
|
||||||
|
appsVer = {}
|
||||||
logexpr = '(?P<ip>[.:0-9a-fA-F]+) - - \[(?P<time>.*?)\] "GET (?P<uri>.*?) HTTP/1.\d" (?P<statuscode>\d+) \d+ "(?P<referral>.*?)" "(?P<useragent>.*?)"'
|
logexpr = '(?P<ip>[.:0-9a-fA-F]+) - - \[(?P<time>.*?)\] "GET (?P<uri>.*?) HTTP/1.\d" (?P<statuscode>\d+) \d+ "(?P<referral>.*?)" "(?P<useragent>.*?)"'
|
||||||
logsearch = re.compile(logexpr).search
|
logsearch = re.compile(logexpr).search
|
||||||
for logfile in glob.glob(os.path.join(logsdir,'access-*.log.gz')):
|
for logfile in glob.glob(os.path.join(logsdir,'access-*.log.gz')):
|
||||||
@ -134,6 +135,12 @@ def main():
|
|||||||
apps[appid] += 1
|
apps[appid] += 1
|
||||||
else:
|
else:
|
||||||
apps[appid] = 1
|
apps[appid] = 1
|
||||||
|
# Strip the '.apk' from apkname
|
||||||
|
appVer = apkname[:-4]
|
||||||
|
if appVer in appsVer:
|
||||||
|
appsVer[appVer] += 1
|
||||||
|
else:
|
||||||
|
appsVer[appVer] = 1
|
||||||
else:
|
else:
|
||||||
if not apkname in unknownapks:
|
if not apkname in unknownapks:
|
||||||
unknownapks.append(apkname)
|
unknownapks.append(apkname)
|
||||||
@ -153,6 +160,12 @@ def main():
|
|||||||
f.write(line + '\n')
|
f.write(line + '\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
f = open('stats/total_downloads_app_version.txt', 'w')
|
||||||
|
f.write('# Total downloads by application and version, since October 2011\n')
|
||||||
|
for appVer, count in sorted(appsVer):
|
||||||
|
f.write(appVer + ' ' + str(count) + '\n')
|
||||||
|
f.close()
|
||||||
|
|
||||||
# Calculate and write stats for repo types...
|
# Calculate and write stats for repo types...
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "Processing repo types..."
|
print "Processing repo types..."
|
||||||
|
Loading…
Reference in New Issue
Block a user