Skip to content

Commit

Permalink
CHG rename and add new visual endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
wabscale committed Feb 18, 2022
1 parent 0490b66 commit ebc83c2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
34 changes: 26 additions & 8 deletions api/anubis/views/public/visuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,55 @@ def public_visuals_usage(course_id: str):
return make_png_response(blob)


@visuals_.route("/usage/active")
def public_visuals_usage_active():
@visuals_.route("/usage/active-14-1")
def public_visuals_usage_active_14_1():
# Get the png blob of the usage graph.
# The get_usage_plot is itself a cached function.
blob = get_usage_plot_active(days=14, step=1)

return make_png_response(blob)


@visuals_.route("/usage/active-half-year")
def public_visuals_usage_active_half_year():
@visuals_.route("/usage/active-180-1")
def public_visuals_usage_active_180_1():
# Get the png blob of the usage graph.
# The get_usage_plot is itself a cached function.
blob = get_usage_plot_active(days=180, step=1)

return make_png_response(blob)


@visuals_.route("/usage/active-month")
def public_visuals_usage_active_month():
@visuals_.route("/usage/active-90-7")
def public_visuals_usage_active_90_7():
# Get the png blob of the usage graph.
# The get_usage_plot is itself a cached function.
blob = get_usage_plot_active(days=90, step=7)

return make_png_response(blob)


@visuals_.route("/users/last-year")
def public_visuals_users_last_year():
@visuals_.route("/usage/active-365-30")
def public_visuals_usage_active_90_7():
# Get the png blob of the usage graph.
# The get_usage_plot is itself a cached function.
blob = get_usage_plot_active(days=365, step=30)

return make_png_response(blob)


@visuals_.route("/users/users-365-1")
def public_visuals_users_365_1():
# Get the png blob of the usage graph.
# The get_usage_plot is itself a cached function.
blob = get_platform_users_plot(days=365, step=1)

return make_png_response(blob)


@visuals_.route("/users/users-365-30")
def public_visuals_users_365_30():
# Get the png blob of the usage graph.
# The get_usage_plot is itself a cached function.
blob = get_platform_users_plot(days=365, step=30)

return make_png_response(blob)
14 changes: 5 additions & 9 deletions api/jobs/visuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ def main():
# Generate playgrounds usage plot
get_usage_plot_playgrounds()

# Generate plot for active in last week
get_usage_plot_active(days=14, step=1)

# Generate plot for active in last month
get_usage_plot_active(days=90, step=7)

# Generate plot for active in last half year
get_usage_plot_active(days=180, step=1)
# Generate plot for active
for days, step in [(14, 1), (90, 7), (180, 1), (365, 30)]:
get_usage_plot_active(days=days, step=step)

# Generate plot for last year registered users
get_platform_users_plot(days=365, step=1)
for days, step in [(365, 1), (365, 30)]:
get_platform_users_plot(days=days, step=step)


if __name__ == "__main__":
Expand Down

0 comments on commit ebc83c2

Please sign in to comment.