chore: remove newrevisiondocevent stats view (#8210)

* refactor: update node, eslint, neostandard + fix esm (#8083)

* chore: update dependencies

* fix: eslint + neostandard

* fix: add corepack prompt env var to init script

* docs: Update README.md

---------

Co-authored-by: Robert Sparks <rjsparks@nostrum.com>

* chore: remove newrevisiondocevent stats view

Not functional anyway

* chore: fix lint

* chore: remove unused template

* Revert "refactor: update node, eslint, neostandard + fix esm (#8083)"

This reverts commit 649879efd745470f6e0cc6768d889f45640e1505.

---------

Co-authored-by: Nicolas Giard <github@ngpixel.com>
Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
This commit is contained in:
Jennifer Richards 2024-11-14 17:21:48 -04:00 committed by GitHub
parent 84a5aa3805
commit 901fdd8d44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1 additions and 136 deletions

View file

@ -2739,60 +2739,6 @@ class DocumentMeetingTests(TestCase):
self.assertIsNone(doc.get_related_meeting(), f'{doc.type.slug} should not be related to meeting')
class ChartTests(ResourceTestCaseMixin, TestCase):
def test_search_chart_conf(self):
doc = IndividualDraftFactory()
conf_url = urlreverse('ietf.doc.views_stats.chart_conf_newrevisiondocevent')
# No qurey arguments; expect an empty json object
r = self.client.get(conf_url)
self.assertValidJSONResponse(r)
self.assertEqual(unicontent(r), '{}')
# No match
r = self.client.get(conf_url + '?activedrafts=on&name=thisisnotadocumentname')
self.assertValidJSONResponse(r)
d = r.json()
self.assertEqual(d['chart']['type'], settings.CHART_TYPE_COLUMN_OPTIONS['chart']['type'])
r = self.client.get(conf_url + '?activedrafts=on&name=%s'%doc.name[6:12])
self.assertValidJSONResponse(r)
d = r.json()
self.assertEqual(d['chart']['type'], settings.CHART_TYPE_COLUMN_OPTIONS['chart']['type'])
self.assertEqual(len(d['series'][0]['data']), 0)
def test_search_chart_data(self):
doc = IndividualDraftFactory()
data_url = urlreverse('ietf.doc.views_stats.chart_data_newrevisiondocevent')
# No qurey arguments; expect an empty json list
r = self.client.get(data_url)
self.assertValidJSONResponse(r)
self.assertEqual(unicontent(r), '[]')
# No match
r = self.client.get(data_url + '?activedrafts=on&name=thisisnotadocumentname')
self.assertValidJSONResponse(r)
d = r.json()
self.assertEqual(unicontent(r), '[]')
r = self.client.get(data_url + '?activedrafts=on&name=%s'%doc.name[6:12])
self.assertValidJSONResponse(r)
d = r.json()
self.assertEqual(len(d), 1)
self.assertEqual(len(d[0]), 2)
def test_search_chart(self):
doc = IndividualDraftFactory()
chart_url = urlreverse('ietf.doc.views_stats.chart_newrevisiondocevent')
r = self.client.get(chart_url)
self.assertEqual(r.status_code, 200)
r = self.client.get(chart_url + '?activedrafts=on&name=%s'%doc.name[6:12])
self.assertEqual(r.status_code, 200)
def test_personal_chart(self):
person = PersonFactory.create()
IndividualDraftFactory.create(

View file

@ -68,10 +68,6 @@ urlpatterns = [
),
url(r'^investigate/?$', views_doc.investigate),
url(r'^stats/newrevisiondocevent/?$', views_stats.chart_newrevisiondocevent),
url(r'^stats/newrevisiondocevent/conf/?$', views_stats.chart_conf_newrevisiondocevent),
url(r'^stats/newrevisiondocevent/data/?$', views_stats.chart_data_newrevisiondocevent),
url(r'^stats/person/(?P<id>[0-9]+)/drafts/conf/?$', views_stats.chart_conf_person_drafts),
url(r'^stats/person/(?P<id>[0-9]+)/drafts/data/?$', views_stats.chart_data_person_drafts),

View file

@ -4,20 +4,15 @@ import copy
import datetime
from django.conf import settings
from django.core.cache import cache
from django.urls import reverse as urlreverse
from django.db.models.aggregates import Count
from django.db.models.functions import TruncDate
from django.http import JsonResponse, HttpResponseBadRequest
from django.shortcuts import render
from django.http import JsonResponse
from django.views.decorators.cache import cache_page
import debug # pyflakes:ignore
from ietf.doc.models import DocEvent
from ietf.doc.templatetags.ietf_filters import comma_separated_list
from ietf.doc.utils import get_search_cache_key
from ietf.doc.views_search import SearchForm, retrieve_search_results
from ietf.name.models import DocTypeName
from ietf.person.models import Person
from ietf.utils.timezone import date_today
@ -113,49 +108,6 @@ def make_title(queryargs):
title += ' with name matching "%s"' % name
return title
def chart_newrevisiondocevent(request):
return render(request, "doc/stats/highstock.html", {
"title": "Document Statistics",
"confurl": urlreverse("ietf.doc.views_stats.chart_conf_newrevisiondocevent"),
"dataurl": urlreverse("ietf.doc.views_stats.chart_data_newrevisiondocevent"),
"queryargs": request.GET.urlencode(),
}
)
#@cache_page(60*15)
def chart_data_newrevisiondocevent(request):
queryargs = request.GET
if queryargs:
cache_key = get_search_cache_key(queryargs)
results = cache.get(cache_key)
if not results:
form = SearchForm(queryargs)
if not form.is_valid():
return HttpResponseBadRequest("form not valid: %s" % form.errors)
results = retrieve_search_results(form)
if results.exists():
cache.set(cache_key, results)
if results.exists():
data = model_to_timeline_data(DocEvent, doc__in=results, type='new_revision')
else:
data = []
else:
data = []
return JsonResponse(data, safe=False)
@cache_page(60*15)
def chart_conf_newrevisiondocevent(request):
queryargs = request.GET
if queryargs:
conf = copy.deepcopy(settings.CHART_TYPE_COLUMN_OPTIONS)
conf['title']['text'] = make_title(queryargs)
conf['series'][0]['name'] = "Submitted %s" % get_doctypes(queryargs, pluralize=True).lower(),
else:
conf = {}
return JsonResponse(conf)
@cache_page(60*15)
def chart_conf_person_drafts(request, id):
person = Person.objects.filter(id=id).first()

View file

@ -1,29 +0,0 @@
{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% load static %}
{% load ietf_filters %}
{% block pagehead %}
<link rel="stylesheet" href="{% static "ietf/css/highcharts.css" %}">
{% endblock %}
{% block js %}
<script src="{% static 'ietf/js/highstock.js' %}"></script>
<script>
$(function () {
var chart;
$.getJSON('{{ confurl }}?{{ queryargs }}', function (conf) {
chart = Highcharts.stockChart('chart', conf);
chart.showLoading();
$.getJSON('{{ dataurl }}?{{ queryargs }}', function (data) {
chart.series[0].setData(data);
chart.hideLoading();
});
});
});
</script>
{% endblock %}
{% block title %}Document Statistics{% endblock %}
{% block content %}
{% origin %}
<div id="chart"></div>
{% endblock %}