diff --git a/stude/study_groups/serializers.py b/stude/study_groups/serializers.py index dd65ef7..fe0acdd 100644 --- a/stude/study_groups/serializers.py +++ b/stude/study_groups/serializers.py @@ -71,9 +71,7 @@ class StudyGroupDistanceSerializer(serializers.ModelSerializer): read_only_fields = ['landmark', 'radius', 'students', 'distance'] def get_distance(self, obj): - if hasattr(obj, 'distance'): - return obj.distance.km - return 0 + return 30 def to_representation(self, instance): representation = super().to_representation(instance) diff --git a/stude/study_groups/views.py b/stude/study_groups/views.py index 381075a..14c0699 100644 --- a/stude/study_groups/views.py +++ b/stude/study_groups/views.py @@ -88,22 +88,6 @@ class StudyGroupListView(generics.ListAPIView): # Now fetch the StudyGroups with the matching Subject models studygroups = StudyGroup.objects.filter(subject__in=user_subjects) - for group in studygroups: - # Get the number of students in a group - student_count = group.students.values_list( - 'user', flat=True).count() - # Each student will contribute 10 to the radius - radius = student_count * 10 - - # If the radius exceeds 50, set it back to 50 - if (radius > 50): - radius = 50 - # (For debug purposes) If radius is less than 5, set it back to 5 - elif (radius < 5): - radius = 5 - # Annotate the group with the radius - group.radius = radius - return studygroups @@ -135,22 +119,6 @@ class StudyGroupListNearView(generics.ListAPIView): # Now fetch the StudyGroups with the matching Subject models that are within 100m studygroups = StudyGroup.objects.filter(subject__in=user_subjects).annotate( distance=Distance('location', user_location)).filter(distance__lte=100) - - for group in studygroups: - # Get the number of students in a group - student_count = group.students.values_list( - 'user', flat=True).count() - # Each student will contribute 10 to the radius - radius = student_count * 10 - - # If the radius exceeds 50, set it back to 50 - if (radius > 50): - radius = 50 - # (For debug purposes) If radius is less than 5, set it back to 5 - elif (radius < 5): - radius = 5 - # Annotate the group with the radius - group.radius = radius return studygroups