1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

Traffic fe (#2363)

* Refactor seafevents msg and add traffic stats API

Squashed commit of the following:

commit 85fe5369f711e1514762d93008f9ebb3c5d49041
Author: zhengxie <xiez1989@gmail.com>
Date:   Mon Aug 6 15:48:55 2018 +0800

    Add '-link' to access_token op type when generate download/upload link

commit 1817833fc3374f54030e16f3a1283ff6f34ddbf5
Author: zhengxie <xiez1989@gmail.com>
Date:   Mon Aug 6 15:28:38 2018 +0800

    Refactor file/dir events

    1. Remove traffic related msg
    2. Rename seahub.stats to seahub.audit for audit related msg

* Fix share link zip task traffic owner

* [admin api] Add org traffic

* [system admin] statistic: added 'traffic', fixed 'storage'

* [system admin] statistic: added 3 more charts for 'traffic', and modified the top nav

* [system admin] statistic: added 'traffic' for org; added a traffic nav, improved chart dot title
This commit is contained in:
llj
2018-09-12 17:41:59 +08:00
committed by Daniel Pan
parent e19a147154
commit b14ddfeb31
25 changed files with 1055 additions and 72 deletions

View File

@@ -65,3 +65,29 @@ class FileOperationsInfoText(BaseTestCase):
self.assertEqual(200, resp.status_code)
data = {'datetime': datetime_to_isoformat_timestr(datetime.datetime(2017, 6, 2, 3, 0)), 'total_storage': 13}
assert data in json_resp
@patch("seahub.api2.endpoints.admin.statistics.EVENTS_ENABLED")
@patch("seahub.api2.endpoints.admin.statistics.is_pro_version")
@patch("seahub.api2.endpoints.admin.statistics.get_system_traffic_by_day")
def test_can_get_system_traffic(self, mock_get_system_traffic_by_day, mock_is_pro, mock_events_enabled):
mock_get_system_traffic_by_day.return_value = [
(datetime.datetime(2018, 8, 23, 0, 0), u'sync-file-download', 131793L),
(datetime.datetime(2018, 8, 23, 0, 0), u'web-file-download', 13L),
]
mock_is_pro.return_value = True
mock_events_enabled = True
url = reverse('api-v2.1-admin-statistics-system-traffic')
url += "?start=2018-08-20 07:00:00&end=2018-08-23 23:00:00"
resp = self.client.get(url)
json_resp = json.loads(resp.content)
self.assertEqual(200, resp.status_code)
assert len(json_resp) == 4
assert json_resp[0]['datetime'] == '2018-08-20T00:00:00+00:00'
assert json_resp[0]['web-file-download'] == 0
assert json_resp[0]['sync-file-download'] == 0
assert json_resp[-1]['datetime'] == '2018-08-23T00:00:00+00:00'
assert json_resp[-1]['web-file-download'] == 13
assert json_resp[-1]['sync-file-download'] == 131793