Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/stats/bin/logprocessor.py

Issue 5901398378020864: Stats processing: don`t count hidden fields for the maximal filter nesting level (Closed)
Patch Set: Created Jan. 27, 2014, 1:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if "application" in info: 423 if "application" in info:
424 info["fullApplication"] = "%s %s" % (info["application"], info["applicationV ersion"]) 424 info["fullApplication"] = "%s %s" % (info["application"], info["applicationV ersion"])
425 if "platform" in info: 425 if "platform" in info:
426 info["fullPlatform"] = "%s %s" % (info["platform"], info["platformVersion"]) 426 info["fullPlatform"] = "%s %s" % (info["platform"], info["platformVersion"])
427 return info 427 return info
428 428
429 def add_record(info, section, ignore_fields=()): 429 def add_record(info, section, ignore_fields=()):
430 section["hits"] = section.get("hits", 0) + 1 430 section["hits"] = section.get("hits", 0) + 1
431 section["bandwidth"] = section.get("bandwidth", 0) + info["size"] 431 section["bandwidth"] = section.get("bandwidth", 0) + info["size"]
432 432
433 if len(ignore_fields) < 2: 433 def is_visible(name):
434 from ..common import fields
435 for field in fields:
436 if field["name"] == name:
437 return "hidden" not in field or not field["hidden"]
Sebastian Noack 2014/01/28 13:30:14 In Python you would do that preferable with one lo
438 return False
439
440 # Allow nesting filters two levels deep but only consider visible fields,
441 # fields that aren't displayed on the web can be nested deeper.
442 filter_level = len(filter(is_visible, ignore_fields))
443 if filter_level < 2:
434 for field in map(lambda f: f["name"], common.fields): 444 for field in map(lambda f: f["name"], common.fields):
435 if field in ignore_fields or field not in info: 445 if field in ignore_fields or field not in info:
436 continue 446 continue
437 447
438 value = info[field] 448 value = info[field]
439 if field not in section: 449 if field not in section:
440 section[field] = {} 450 section[field] = {}
441 if value not in section[field]: 451 if value not in section[field]:
442 section[field][value] = {} 452 section[field][value] = {}
443 453
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 parser.add_argument("mirror_name", nargs="?", help="Name of the mirror server that the file belongs to") 547 parser.add_argument("mirror_name", nargs="?", help="Name of the mirror server that the file belongs to")
538 parser.add_argument("server_type", nargs="?", help="Server type like download, update or subscription") 548 parser.add_argument("server_type", nargs="?", help="Server type like download, update or subscription")
539 parser.add_argument("log_file", nargs="?", help="Log file path, can be a local file path, http:// or ssh:// URL") 549 parser.add_argument("log_file", nargs="?", help="Log file path, can be a local file path, http:// or ssh:// URL")
540 args = parser.parse_args() 550 args = parser.parse_args()
541 551
542 if args.mirror_name and args.server_type and args.log_file: 552 if args.mirror_name and args.server_type and args.log_file:
543 sources = [(args.mirror_name, args.server_type, args.log_file)] 553 sources = [(args.mirror_name, args.server_type, args.log_file)]
544 else: 554 else:
545 sources = get_stats_files() 555 sources = get_stats_files()
546 parse_sources(sources, args.factor, args.verbose) 556 parse_sources(sources, args.factor, args.verbose)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld