Skip to content

Commit

Permalink
Clean up unused contentnode api endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Jun 14, 2024
1 parent b197fdf commit 7eb53e1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 50 deletions.
3 changes: 0 additions & 3 deletions kolibri/core/assets/src/api-resources/contentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ export default new Resource({
fetchDescendantsAssessments(ids) {
return this.getListEndpoint('descendants_assessments', { ids });
},
fetchNodeAssessments(ids) {
return this.getListEndpoint('node_assessments', { ids });
},
fetchRecommendationsFor(id, getParams) {
return this.fetchDetailCollection('recommendations_for', id, getParams);
},
Expand Down
19 changes: 0 additions & 19 deletions kolibri/core/content/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from django.db.models import OuterRef
from django.db.models import Q
from django.db.models import Subquery
from django.db.models import Sum
from django.db.models.aggregates import Count
from django.http import Http404
from django.utils.cache import add_never_cache_headers
Expand Down Expand Up @@ -925,24 +924,6 @@ def descendants_assessments(self, request):
)
return Response(data)

@action(detail=False)
def node_assessments(self, request):
ids = self.request.query_params.get("ids", "").split(",")
data = 0
if ids and ids[0]:
nodes = (
models.ContentNode.objects.filter_by_uuids(ids)
.filter(available=True)
.prefetch_related("assessmentmetadata")
)
data = (
nodes.aggregate(Sum("assessmentmetadata__number_of_assessments"))[
"assessmentmetadata__number_of_assessments__sum"
]
or 0
)
return Response(data)

@action(detail=True)
def recommendations_for(self, request, **kwargs):
"""
Expand Down
28 changes: 0 additions & 28 deletions kolibri/core/content/test/test_content_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,34 +1142,6 @@ def test_contentnode_descendants_availability(self):
)
self.assertEqual(len(response.data), 0)

def test_contentnode_node_assessments_available(self):
content.ContentNode.objects.all().update(available=True)
root = content.ContentNode.objects.get(parent__isnull=True)
exercise_ids = (
root.get_descendants()
.filter(kind=content_kinds.EXERCISE)
.values_list("id", flat=True)
)
response = self.client.get(
reverse("kolibri:core:contentnode-node-assessments"),
data={"ids": ",".join(exercise_ids)},
)
self.assertEqual(response.data, 1)

def test_contentnode_node_assessments_not_available(self):
content.ContentNode.objects.all().update(available=False)
root = content.ContentNode.objects.get(parent__isnull=True)
exercise_ids = (
root.get_descendants()
.filter(kind=content_kinds.EXERCISE)
.values_list("id", flat=True)
)
response = self.client.get(
reverse("kolibri:core:contentnode-node-assessments"),
data={"ids": ",".join(exercise_ids)},
)
self.assertEqual(response.data, 0)

def test_contentnode_recommendations(self):
node_id = content.ContentNode.objects.get(title="c2c2").id
response = self.client.get(
Expand Down

0 comments on commit 7eb53e1

Please sign in to comment.