mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
Add ability to filter asshattery from stats
This commit is contained in:
parent
58a88acd92
commit
b43f7bea1a
3 changed files with 25 additions and 14 deletions
|
@ -165,6 +165,10 @@ wiki_password = "1234"
|
||||||
# machine.
|
# machine.
|
||||||
update_stats = False
|
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:
|
# Use the following to push stats to a Carbon instance:
|
||||||
stats_to_carbon = False
|
stats_to_carbon = False
|
||||||
carbon_host = '0.0.0.0'
|
carbon_host = '0.0.0.0'
|
||||||
|
|
|
@ -49,6 +49,7 @@ def get_default_config():
|
||||||
'gradle': 'gradle',
|
'gradle': 'gradle',
|
||||||
'sync_from_local_copy_dir': False,
|
'sync_from_local_copy_dir': False,
|
||||||
'update_stats': False,
|
'update_stats': False,
|
||||||
|
'stats_ignore': [],
|
||||||
'stats_to_carbon': False,
|
'stats_to_carbon': False,
|
||||||
'repo_maxage': 0,
|
'repo_maxage': 0,
|
||||||
'build_server_always': False,
|
'build_server_always': False,
|
||||||
|
|
|
@ -154,20 +154,26 @@ def main():
|
||||||
p = subprocess.Popen(["zcat", logfile], stdout=subprocess.PIPE)
|
p = subprocess.Popen(["zcat", logfile], stdout=subprocess.PIPE)
|
||||||
matches = (logsearch(line) for line in p.stdout)
|
matches = (logsearch(line) for line in p.stdout)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
if match and match.group('statuscode') == '200':
|
if not match:
|
||||||
uri = match.group('uri')
|
continue
|
||||||
if uri.endswith('.apk'):
|
if match.group('statuscode') != '200':
|
||||||
_, apkname = os.path.split(uri)
|
continue
|
||||||
app = knownapks.getapp(apkname)
|
if match.group('ip') in config['stats_ignore']:
|
||||||
if app:
|
continue
|
||||||
appid, _ = app
|
uri = match.group('uri')
|
||||||
today['apps'][appid] += 1
|
if not uri.endswith('.apk'):
|
||||||
# Strip the '.apk' from apkname
|
continue
|
||||||
appver = apkname[:-4]
|
_, apkname = os.path.split(uri)
|
||||||
today['appsver'][appver] += 1
|
app = knownapks.getapp(apkname)
|
||||||
else:
|
if app:
|
||||||
if apkname not in today['unknown']:
|
appid, _ = app
|
||||||
today['unknown'].append(apkname)
|
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
|
# Save calculated aggregate data for today to cache
|
||||||
with open(agg_path, 'w') as f:
|
with open(agg_path, 'w') as f:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue