From 229ed0d7dc094c417ce755be84af1d97b36d2757 Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Tue, 18 Oct 2016 16:49:31 -0500 Subject: [PATCH] rename summarize to summarize_and_reset --- lbrynet/analytics/manager.py | 2 +- lbrynet/analytics/track.py | 2 +- tests/unit/analytics/test_track.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lbrynet/analytics/manager.py b/lbrynet/analytics/manager.py index 455342946..fecc1a0d2 100644 --- a/lbrynet/analytics/manager.py +++ b/lbrynet/analytics/manager.py @@ -44,7 +44,7 @@ class Manager(object): self.analytics_api.track(heartbeat) def _update_tracked_metrics(self): - should_send, value = self.track.summarize(constants.BLOB_BYTES_UPLOADED) + should_send, value = self.track.summarize_and_reset(constants.BLOB_BYTES_UPLOADED) if should_send: event = self.events_generator.metric_observed(constants.BLOB_BYTES_UPLOADED, value) self.analytics_api.track(event) diff --git a/lbrynet/analytics/track.py b/lbrynet/analytics/track.py index 35dc27160..7643ebce9 100644 --- a/lbrynet/analytics/track.py +++ b/lbrynet/analytics/track.py @@ -9,7 +9,7 @@ class Track(object): def add_observation(self, metric, value): self.data[metric].append(value) - def summarize(self, metric, op=sum): + def summarize_and_reset(self, metric, op=sum): """Apply `op` on the current values for `metric`. This operation also resets the metric. diff --git a/tests/unit/analytics/test_track.py b/tests/unit/analytics/test_track.py index fcfbe0346..531ec56a5 100644 --- a/tests/unit/analytics/test_track.py +++ b/tests/unit/analytics/test_track.py @@ -6,7 +6,7 @@ from twisted.trial import unittest class TrackTest(unittest.TestCase): def test_empty_summarize_is_None(self): track = analytics.Track() - _, result = track.summarize('a') + _, result = track.summarize_and_reset('a') self.assertEqual(None, result) def test_can_get_sum_of_metric(self): @@ -14,7 +14,7 @@ class TrackTest(unittest.TestCase): track.add_observation('b', 1) track.add_observation('b', 2) - _, result = track.summarize('b') + _, result = track.summarize_and_reset('b') self.assertEqual(3, result) def test_summarize_resets_metric(self): @@ -22,6 +22,6 @@ class TrackTest(unittest.TestCase): track.add_observation('metric', 1) track.add_observation('metric', 2) - track.summarize('metric') - _, result = track.summarize('metric') + track.summarize_and_reset('metric') + _, result = track.summarize_and_reset('metric') self.assertEqual(None, result)