Skip to content

Commit

Permalink
chore: remove newrevisiondocevent stats view (#8210)
Browse files Browse the repository at this point in the history
* 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 649879e.

---------

Co-authored-by: Nicolas Giard <github@ngpixel.com>
Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
  • Loading branch information
3 people authored Nov 14, 2024
1 parent 84a5aa3 commit 901fdd8
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 136 deletions.
54 changes: 0 additions & 54 deletions ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2739,60 +2739,6 @@ def test_get_related_meeting(self):
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(
Expand Down
4 changes: 0 additions & 4 deletions ietf/doc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@
),
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),

Expand Down
50 changes: 1 addition & 49 deletions ietf/doc/views_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@
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
Expand Down Expand Up @@ -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()
Expand Down
29 changes: 0 additions & 29 deletions ietf/templates/doc/stats/highstock.html

This file was deleted.

0 comments on commit 901fdd8

Please sign in to comment.