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: Added test case Created May 22, 2014, 8:40 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 | sitescripts/stats/test/logprocessor.py » ('j') | 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 221 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") 545 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") 546 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") 547 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() 548 args = parser.parse_args()
546 549
547 if args.mirror_name and args.server_type and args.log_file: 550 if args.mirror_name and args.server_type and args.log_file:
548 sources = [(args.mirror_name, args.server_type, args.log_file)] 551 sources = [(args.mirror_name, args.server_type, args.log_file)]
549 else: 552 else:
550 sources = get_stats_files() 553 sources = get_stats_files()
551 parse_sources(sources, args.factor, args.verbose) 554 parse_sources(sources, args.factor, args.verbose)
OLDNEW
« no previous file with comments | « no previous file | sitescripts/stats/test/logprocessor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld