forked from LBRYCommunity/lbry-sdk
rename summarize to summarize_and_reset
This commit is contained in:
parent
7f800ce5bb
commit
229ed0d7dc
3 changed files with 6 additions and 6 deletions
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue