Organise views

This commit is contained in:
George Lacey 2022-04-11 07:02:05 +01:00
parent 0b2daf3786
commit c973bc9fda
4 changed files with 17 additions and 8 deletions

View File

@ -28,7 +28,7 @@ window.addEventListener("DOMContentLoaded", function () {
inflateRepo(repo_json, repo_label, template, container);
})
$.getJSON(`/repo/${repo_label}/size.json`, function (repo_size_json) {
$.getJSON(`/repo/${repo_label}/monthly-size.json`, function (repo_size_json) {
draw_time_series_graph(`repo-${repo_label}-size-graph`, repo_size_json.repo,
repo_size_json.dates, repo_size_json.units);
})

View File

@ -4,15 +4,24 @@ from django.views.decorators.cache import cache_page
from . import views
urlpatterns = [
# Pages
path('', cache_page(60)(views.index), name='index'),
path('repo_daily.json', cache_page(3600)(views.repo_daily_json), name='daily repo json'),
path('repo_monthly.json', cache_page(3600 * 12)(views.repo_monthly_json), name='monthly repo json'),
path('repo_list.json', cache_page(60)(views.repo_list_json), name='repo list'),
path('repo/<str:repo_label>/size.json', cache_page(3600)(views.repo_size_json), name='repo size time series'),
path('repo/<str:repo_label>.json', cache_page(60)(views.repo_json), name='repo json'),
path('repo/<str:repo_label>', cache_page(60)(views.repo), name='repo'),
path('repo_list.json', cache_page(60)(views.repo_list_json), name='repo list'),
# Repo
path('repo/<str:repo_label>/monthly-size.json', cache_page(3600)(views.repo_monthly_size_json),
name='repo size time series'),
path('repo/<str:repo_label>.json', cache_page(60)(views.repo_json), name='repo json'),
# POST
path('post/repo', views.post_repo, name='post repo'),
path('post/archive', views.post_archive, name='post archive'),
path('post/error', views.post_error, name='post error'),
path('post/location', views.post_location, name='post location'),
# Unused
path('repo_daily.json', cache_page(3600)(views.repo_daily_json), name='daily repo json'),
path('repo_monthly.json', cache_page(3600 * 12)(views.repo_monthly_json), name='monthly repo json'),
]

View File

@ -1,3 +1,3 @@
from .views import index, repo, axes
from .post import post_repo, post_archive, post_error, post_location
from .json import repo_daily_json, repo_monthly_json, repo_list_json, repo_json, repo_size_json
from .json import repo_daily_json, repo_monthly_json, repo_list_json, repo_json, repo_monthly_size_json

View File

@ -17,7 +17,7 @@ def repo_json(request, repo_label):
return JsonResponse(repo_dict)
def repo_size_json(request, repo_label, months_ago: int = 12):
def repo_monthly_size_json(request, repo_label, months_ago: int = 12):
repo = get_object_or_404(Repo, label__label=repo_label)
date_labels = [date.strftime("%b %Y") for date in last_day_previous_months(months_ago)]