Add grouping to the remaining graphs

This commit is contained in:
JonnyWong16 2018-02-18 12:50:28 -08:00
parent 4ab9eb3bfa
commit 87c6ad66fb
3 changed files with 184 additions and 98 deletions

View file

@ -1807,10 +1807,10 @@ class WebInterface(object):
None
Optional parameters:
grouping (int): 0 or 1
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -1824,10 +1824,7 @@ class WebInterface(object):
}
```
"""
if grouping and str(grouping).isdigit():
grouping = int(grouping)
elif grouping == 'false':
grouping = 0
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_total_plays_per_day(time_range=time_range, user_id=user_id, y_axis=y_axis, grouping=grouping)
@ -1841,7 +1838,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_plays_by_dayofweek(self, time_range='30', user_id=None, y_axis='plays', **kwargs):
def get_plays_by_dayofweek(self, time_range='30', user_id=None, y_axis='plays', grouping=None, **kwargs):
""" Get graph data by day of the week.
```
@ -1852,6 +1849,7 @@ class WebInterface(object):
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -1865,6 +1863,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_total_plays_per_dayofweek(time_range=time_range, user_id=user_id, y_axis=y_axis)
@ -1877,7 +1877,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_plays_by_hourofday(self, time_range='30', user_id=None, y_axis='plays', **kwargs):
def get_plays_by_hourofday(self, time_range='30', user_id=None, y_axis='plays', grouping=None, **kwargs):
""" Get graph data by hour of the day.
```
@ -1888,6 +1888,7 @@ class WebInterface(object):
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -1901,6 +1902,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_total_plays_per_hourofday(time_range=time_range, user_id=user_id, y_axis=y_axis)
@ -1913,7 +1916,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_plays_per_month(self, time_range='12', y_axis='plays', user_id=None, **kwargs):
def get_plays_per_month(self, time_range='12', y_axis='plays', user_id=None, grouping=None, **kwargs):
""" Get graph data by month.
```
@ -1924,6 +1927,7 @@ class WebInterface(object):
time_range (str): The number of months of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -1937,6 +1941,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_total_plays_per_month(time_range=time_range, y_axis=y_axis, user_id=user_id)
@ -1949,7 +1955,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_plays_by_top_10_platforms(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
def get_plays_by_top_10_platforms(self, time_range='30', y_axis='plays', grouping=None, user_id=None, **kwargs):
""" Get graph data by top 10 platforms.
```
@ -1960,6 +1966,7 @@ class WebInterface(object):
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -1973,6 +1980,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_total_plays_by_top_10_platforms(time_range=time_range, y_axis=y_axis, user_id=user_id)
@ -1985,7 +1994,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_plays_by_top_10_users(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
def get_plays_by_top_10_users(self, time_range='30', y_axis='plays', grouping=None, user_id=None, **kwargs):
""" Get graph data by top 10 users.
```
@ -1996,6 +2005,7 @@ class WebInterface(object):
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -2009,6 +2019,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_total_plays_by_top_10_users(time_range=time_range, y_axis=y_axis, user_id=user_id)
@ -2021,7 +2033,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_plays_by_stream_type(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
def get_plays_by_stream_type(self, time_range='30', y_axis='plays', grouping=None, user_id=None, **kwargs):
""" Get graph data by stream type by date.
```
@ -2032,6 +2044,7 @@ class WebInterface(object):
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -2045,6 +2058,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_total_plays_per_stream_type(time_range=time_range, y_axis=y_axis, user_id=user_id)
@ -2057,7 +2072,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_plays_by_source_resolution(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
def get_plays_by_source_resolution(self, time_range='30', y_axis='plays', grouping=None, user_id=None, **kwargs):
""" Get graph data by source resolution.
```
@ -2068,6 +2083,7 @@ class WebInterface(object):
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -2081,6 +2097,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_total_plays_by_source_resolution(time_range=time_range, y_axis=y_axis, user_id=user_id)
@ -2093,7 +2111,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_plays_by_stream_resolution(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
def get_plays_by_stream_resolution(self, time_range='30', y_axis='plays', grouping=None, user_id=None, **kwargs):
""" Get graph data by stream resolution.
```
@ -2104,6 +2122,7 @@ class WebInterface(object):
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -2117,6 +2136,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_total_plays_by_stream_resolution(time_range=time_range, y_axis=y_axis, user_id=user_id)
@ -2129,7 +2150,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_stream_type_by_top_10_users(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
def get_stream_type_by_top_10_users(self, time_range='30', y_axis='plays', grouping=None, user_id=None, **kwargs):
""" Get graph data by stream type by top 10 users.
```
@ -2140,6 +2161,7 @@ class WebInterface(object):
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -2153,6 +2175,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_stream_type_by_top_10_users(time_range=time_range, y_axis=y_axis, user_id=user_id)
@ -2165,7 +2189,7 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_stream_type_by_top_10_platforms(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
def get_stream_type_by_top_10_platforms(self, time_range='30', y_axis='plays', grouping=None, user_id=None, **kwargs):
""" Get graph data by stream type by top 10 platforms.
```
@ -2176,6 +2200,7 @@ class WebInterface(object):
time_range (str): The number of days of data to return
y_axis (str): "plays" or "duration"
user_id (str): The user id to filter the data
grouping (int): 0 or 1
Returns:
json:
@ -2189,6 +2214,8 @@ class WebInterface(object):
}
```
"""
grouping = int(grouping) if str(grouping).isdigit() else grouping
graph = graphs.Graphs()
result = graph.get_stream_type_by_top_10_platforms(time_range=time_range, y_axis=y_axis, user_id=user_id)