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

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

Issue 5438786527821824: Issue 527 - Only process notification requests sent by our own extensions (Closed)
Patch Set: Addressed comments Created May 22, 2014, 8:21 a.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-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 diff = info["time"] - last_update 292 diff = info["time"] - last_update
293 if diff.days >= 365: 293 if diff.days >= 365:
294 info["downloadInterval"] = "%i year(s)" % (diff.days / 365) 294 info["downloadInterval"] = "%i year(s)" % (diff.days / 365)
295 elif diff.days >= 30: 295 elif diff.days >= 30:
296 info["downloadInterval"] = "%i month(s)" % (diff.days / 30) 296 info["downloadInterval"] = "%i month(s)" % (diff.days / 30)
297 elif diff.days >= 1: 297 elif diff.days >= 1:
298 info["downloadInterval"] = "%i day(s)" % diff.days 298 info["downloadInterval"] = "%i day(s)" % diff.days
299 else: 299 else:
300 info["downloadInterval"] = "%i hour(s)" % (diff.seconds / 3600) 300 info["downloadInterval"] = "%i hour(s)" % (diff.seconds / 3600)
301 301
302 diffdays = (info["time"].date() - last_update.date()).days 302 if info["addonName"].startswith("adblockplus"):
303 if diffdays == 0: 303 diffdays = (info["time"].date() - last_update.date()).days
304 info["previousDownload"] = "same day" 304 if diffdays == 0:
305 elif diffdays < 30: 305 info["previousDownload"] = "same day"
306 info["previousDownload"] = "%i day(s)" % diffdays 306 elif diffdays < 30:
307 elif diffdays < 365: 307 info["previousDownload"] = "%i day(s)" % diffdays
308 info["previousDownload"] = "%i month(s)" % (diffdays / 30) 308 elif diffdays < 365:
309 info["previousDownload"] = "%i month(s)" % (diffdays / 30)
310 else:
311 info["previousDownload"] = "%i year(s)" % (diffdays / 365)
309 else: 312 else:
310 info["previousDownload"] = "%i year(s)" % (diffdays / 365) 313 info["previousDownload"] = "unknown"
311 314
312 if last_update.year != info["time"].year or last_update.month != info["tim e"].month: 315 if last_update.year != info["time"].year or last_update.month != info["tim e"].month:
313 info["firstInMonth"] = info["firstInDay"] = True 316 info["firstInMonth"] = info["firstInDay"] = True
314 elif last_update.day != info["time"].day: 317 elif last_update.day != info["time"].day:
315 info["firstInDay"] = True 318 info["firstInDay"] = True
316 319
317 if get_week(last_update) != get_week(info["time"]): 320 if get_week(last_update) != get_week(info["time"]):
318 info["firstInWeek"] = True 321 info["firstInWeek"] = True
319 except ValueError: 322 except ValueError:
320 info["downloadInterval"] = "unknown" 323 info["downloadInterval"] = "unknown"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 else: 421 else:
419 ignored.add(info["file"]) 422 ignored.add(info["file"])
420 return None 423 return None
421 424
422 if "addonName" in info: 425 if "addonName" in info:
423 info["fullAddon"] = "%s %s" % (info["addonName"], info["addonVersion"]) 426 info["fullAddon"] = "%s %s" % (info["addonName"], info["addonVersion"])
424 if "application" in info: 427 if "application" in info:
425 info["fullApplication"] = "%s %s" % (info["application"], info["applicationV ersion"]) 428 info["fullApplication"] = "%s %s" % (info["application"], info["applicationV ersion"])
426 if "platform" in info: 429 if "platform" in info:
427 info["fullPlatform"] = "%s %s" % (info["platform"], info["platformVersion"]) 430 info["fullPlatform"] = "%s %s" % (info["platform"], info["platformVersion"])
431
Felix Dahlke 2014/05/22 08:30:38 Unrelated whitespace change?
Sebastian Noack 2014/05/22 08:40:39 Done.
428 return info 432 return info
429 433
430 def add_record(info, section, ignore_fields=()): 434 def add_record(info, section, ignore_fields=()):
431 section["hits"] = section.get("hits", 0) + 1 435 section["hits"] = section.get("hits", 0) + 1
432 section["bandwidth"] = section.get("bandwidth", 0) + info["size"] 436 section["bandwidth"] = section.get("bandwidth", 0) + info["size"]
433 437
434 if len(ignore_fields) < 2: 438 if len(ignore_fields) < 2:
435 for field in map(lambda f: f["name"], common.fields): 439 for field in map(lambda f: f["name"], common.fields):
436 if field in ignore_fields or field not in info: 440 if field in ignore_fields or field not in info:
437 continue 441 continue
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 parser.add_argument("mirror_name", nargs="?", help="Name of the mirror server that the file belongs to") 546 parser.add_argument("mirror_name", nargs="?", help="Name of the mirror server that the file belongs to")
543 parser.add_argument("server_type", nargs="?", help="Server type like download, update or subscription") 547 parser.add_argument("server_type", nargs="?", help="Server type like download, update or subscription")
544 parser.add_argument("log_file", nargs="?", help="Log file path, can be a local file path, http:// or ssh:// URL") 548 parser.add_argument("log_file", nargs="?", help="Log file path, can be a local file path, http:// or ssh:// URL")
545 args = parser.parse_args() 549 args = parser.parse_args()
546 550
547 if args.mirror_name and args.server_type and args.log_file: 551 if args.mirror_name and args.server_type and args.log_file:
548 sources = [(args.mirror_name, args.server_type, args.log_file)] 552 sources = [(args.mirror_name, args.server_type, args.log_file)]
549 else: 553 else:
550 sources = get_stats_files() 554 sources = get_stats_files()
551 parse_sources(sources, args.factor, args.verbose) 555 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