From 751dff374f14fe995d8864523be789420f71e02e Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 25 Oct 2014 13:58:25 +0200 Subject: Properly calculate ban duration in months instead of days --- main.py | 3 +-- wikibania/ban/Ban.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index fc3069b..d6ebe3d 100644 --- a/main.py +++ b/main.py @@ -49,8 +49,7 @@ ban_db_wrapper = BanDBWrapper(ban_db) # HISTOGRAM ban_durations = ban_db_wrapper.get_all_durations() -duration_bins = [round(365 / 12 * x) for x in range(1, 50 + 2)] -(ban_durations_bars, bins) = np.histogram(ban_durations, bins=duration_bins) +(ban_durations_bars, bins) = np.histogram(ban_durations, bins=range(1, 50 + 2)) bar_chart = pygal.Bar(legend_at_bottom=True) bar_chart.title = "Active Wikipedia bans by duration (%d samples)" % len(ban_db.list()) diff --git a/wikibania/ban/Ban.py b/wikibania/ban/Ban.py index e06ca89..c6a55b4 100644 --- a/wikibania/ban/Ban.py +++ b/wikibania/ban/Ban.py @@ -28,7 +28,7 @@ class Ban: self.expiry = datetime.strptime(ban_dict["expiry"], ISO_TIMESTAMP) def calc_duration(self): - return (self.expiry - self.timestamp).days + return (self.expiry - self.timestamp).days / round(365 / 12) def lookup_country_code(self): try: -- cgit v1.2.3