mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-03 17:50:11 +02:00
Add ability to filter asshattery from stats
This commit is contained in:
parent
58a88acd92
commit
b43f7bea1a
@ -165,6 +165,10 @@ wiki_password = "1234"
|
||||
# machine.
|
||||
update_stats = False
|
||||
|
||||
# When used with stats, this is a list of IP addresses that are ignored for
|
||||
# calculation purposes.
|
||||
stats_ignore = []
|
||||
|
||||
# Use the following to push stats to a Carbon instance:
|
||||
stats_to_carbon = False
|
||||
carbon_host = '0.0.0.0'
|
||||
|
@ -49,6 +49,7 @@ def get_default_config():
|
||||
'gradle': 'gradle',
|
||||
'sync_from_local_copy_dir': False,
|
||||
'update_stats': False,
|
||||
'stats_ignore': [],
|
||||
'stats_to_carbon': False,
|
||||
'repo_maxage': 0,
|
||||
'build_server_always': False,
|
||||
|
@ -154,20 +154,26 @@ def main():
|
||||
p = subprocess.Popen(["zcat", logfile], stdout=subprocess.PIPE)
|
||||
matches = (logsearch(line) for line in p.stdout)
|
||||
for match in matches:
|
||||
if match and match.group('statuscode') == '200':
|
||||
uri = match.group('uri')
|
||||
if uri.endswith('.apk'):
|
||||
_, apkname = os.path.split(uri)
|
||||
app = knownapks.getapp(apkname)
|
||||
if app:
|
||||
appid, _ = app
|
||||
today['apps'][appid] += 1
|
||||
# Strip the '.apk' from apkname
|
||||
appver = apkname[:-4]
|
||||
today['appsver'][appver] += 1
|
||||
else:
|
||||
if apkname not in today['unknown']:
|
||||
today['unknown'].append(apkname)
|
||||
if not match:
|
||||
continue
|
||||
if match.group('statuscode') != '200':
|
||||
continue
|
||||
if match.group('ip') in config['stats_ignore']:
|
||||
continue
|
||||
uri = match.group('uri')
|
||||
if not uri.endswith('.apk'):
|
||||
continue
|
||||
_, apkname = os.path.split(uri)
|
||||
app = knownapks.getapp(apkname)
|
||||
if app:
|
||||
appid, _ = app
|
||||
today['apps'][appid] += 1
|
||||
# Strip the '.apk' from apkname
|
||||
appver = apkname[:-4]
|
||||
today['appsver'][appver] += 1
|
||||
else:
|
||||
if apkname not in today['unknown']:
|
||||
today['unknown'].append(apkname)
|
||||
|
||||
# Save calculated aggregate data for today to cache
|
||||
with open(agg_path, 'w') as f:
|
||||
|
Loading…
Reference in New Issue
Block a user