Skip to content

Commit

Permalink
Remove Human Readable Online Stats
Browse files Browse the repository at this point in the history
  • Loading branch information
super3 committed Oct 23, 2015
1 parent b317e6b commit a2cea5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
16 changes: 0 additions & 16 deletions dataserv/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,6 @@ def get_address():
return jsonify({"address": app.config["ADDRESS"]})


@app.route('/api/online', methods=["GET"])
@cache.cached(timeout=app.config["CACHING_TIME"], unless=disable_caching)
def online():
"""Display a readable list of online farmers."""
logger.info("CALLED /api/online")
output = ""
current_time = datetime.datetime.utcnow()
text = "{0} | Last Seen: {1} | Height: {2}<br/>"

for farmer in online_farmers():
last_seen = secs_to_mins((current_time - farmer.last_seen).seconds)
output += text.format(farmer.payout_addr, last_seen, farmer.height)

return output


@app.route('/api/online/json', methods=["GET"])
@cache.cached(timeout=app.config["CACHING_TIME"], unless=disable_caching)
def online_json():
Expand Down
13 changes: 3 additions & 10 deletions tests/test_App.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_online(self):
self.app.get('/api/ping/{0}'.format(btc_addr))

# get online data
rv = self.app.get('/api/online')
rv = self.app.get('/api/online/json')

# see if that address is in the online status
self.assertTrue(btc_addr in str(rv.data))
Expand Down Expand Up @@ -239,7 +239,7 @@ def test_farmer_set_height(self):
# correct
rv = self.app.get('/api/height/{0}/5'.format(btc_addr))
self.assertEqual(rv.status_code, 200)
rv = self.app.get('/api/online'.format(btc_addr))
rv = self.app.get('/api/online/json'.format(btc_addr))
self.assertTrue(b"5" in rv.data)

# invalid btc address
Expand All @@ -252,7 +252,7 @@ def test_height_limit(self):

# set height 50
self.app.get('/api/height/{0}/{1}'.format(btc_addr, 50))
rv = self.app.get('/api/online')
rv = self.app.get('/api/online/json')
self.assertTrue(b"50" in rv.data)

# set a crazy height
Expand Down Expand Up @@ -413,13 +413,6 @@ def test_farmer_total_bytes(self):
self.app.get('/api/height/{0}/{1}'.format(addr3, 2525))
self.app.get('/api/height/{0}/{1}'.format(addr4, 5000))

# check online
rv = self.app.get('/api/online')
self.assertTrue(b"0" in rv.data)
self.assertTrue(b"2475" in rv.data)
self.assertTrue(b"2525" in rv.data)
self.assertTrue(b"5000" in rv.data)

# check total bytes
rv = self.app.get('/api/total')
self.assertTrue(b'"total_TB": 1.22' in rv.data)
Expand Down

0 comments on commit a2cea5d

Please sign in to comment.