<commit_before>#from django.contrib.auth.models import User, Group
from rest_framework import generics
from .serializers import (
    UserSerializer,
    ForumSerializer,
    TopicSerializer,
    PostSerializer,
)

class UsersReadView(generics.ListAPIView):
    serializer_class = UserSerializer
    model = serializer_class.Meta.model
    queryset = model.objects.exclude(user_type=2) # exclude bot
    paginate_by = 100

class UserReadView(generics.RetrieveAPIView):
    serializer_class = UserSerializer
    model = serializer_class.Meta.model
    lookup_field = 'user_id'

class UserPostsReadView(generics.ListAPIView):
    serializer_class = PostSerializer
    model = serializer_class.Meta.model
    queryset = model.objects.order_by('post_time').reverse()
    lookup_field = 'poster_id'
    paginate_by = 100

class ForumsReadView(generics.ListAPIView):
    serializer_class = ForumSerializer
    model = serializer_class.Meta.model

class ForumReadView(generics.RetrieveAPIView):
    serializer_class = ForumSerializer
    model = serializer_class.Meta.model
    lookup_field = 'forum_id'

class TopicsReadView(generics.ListAPIView):
    serializer_class = TopicSerializer
    model = serializer_class.Meta.model
    queryset = model.objects.order_by('topic_time').reverse()
    paginate_by = 100

class TopicReadView(generics.RetrieveAPIView):
    serializer_class = TopicSerializer
    model = serializer_class.Meta.model
    lookup_field = 'topic_id'

class TopicPostsReadView(generics.ListAPIView):
    serializer_class = PostSerializer
    model = serializer_class.Meta.model
    queryset = model.objects.order_by('post_time').reverse()
    lookup_field = 'topic_id'
    paginate_by = 100

class PostsReadView(generics.ListAPIView):
    serializer_class = PostSerializer
    model = serializer_class.Meta.model
    queryset = model.objects.order_by('post_time').reverse()
    paginate_by = 100

class PostReadView(generics.RetrieveAPIView):
    serializer_class = PostSerializer
    model = serializer_class.Meta.model
    lookup_field = 'post_id'<commit_msg>Fixed bug regarding UserPostsReadView and TopicPostsReadView<commit_after>#from django.contrib.auth.models import User, Group
from rest_framework import generics
from .serializers import (
    UserSerializer,
    ForumSerializer,
    TopicSerializer,
    PostSerializer,
)

class UsersReadView(generics.ListAPIView):
    serializer_class = UserSerializer
    model = serializer_class.Meta.model
    queryset = model.objects.exclude(user_type=2) # exclude bot
    paginate_by = 100

class UserReadView(generics.RetrieveAPIView):
    serializer_class = UserSerializer
    model = serializer_class.Meta.model
    lookup_field = 'user_id'

class UserPostsReadView(generics.ListAPIView):
    serializer_class = PostSerializer
    model = serializer_class.Meta.model
    paginate_by = 100
    def get_queryset(self):
        poster_id = self.kwargs['poster_id']
        queryset = self.model.objects.filter(poster_id=poster_id)
        return queryset.order_by('-post_time')

class ForumsReadView(generics.ListAPIView):
    serializer_class = ForumSerializer
    model = serializer_class.Meta.model

class ForumReadView(generics.RetrieveAPIView):
    serializer_class = ForumSerializer
    model = serializer_class.Meta.model
    lookup_field = 'forum_id'

class TopicsReadView(generics.ListAPIView):
    serializer_class = TopicSerializer
    model = serializer_class.Meta.model
    queryset = model.objects.order_by('-topic_time')
    paginate_by = 100

class TopicReadView(generics.RetrieveAPIView):
    serializer_class = TopicSerializer
    model = serializer_class.Meta.model
    lookup_field = 'topic_id'

class TopicPostsReadView(generics.ListAPIView):
    serializer_class = PostSerializer
    model = serializer_class.Meta.model
    paginate_by = 100
    def get_queryset(self):
        topic_id = self.kwargs['topic_id']
        queryset = self.model.objects.filter(topic_id=topic_id)
        return queryset.order_by('-post_time')

class PostsReadView(generics.ListAPIView):
    serializer_class = PostSerializer
    model = serializer_class.Meta.model
    queryset = model.objects.order_by('-post_time')
    paginate_by = 100

class PostReadView(generics.RetrieveAPIView):
    serializer_class = PostSerializer
    model = serializer_class.Meta.model
    lookup_field = 'post_id'
{'fraction_non_alphanumeric': 0.07893529141808169, 'fraction_numerical': 0.0073428178063331805, 'mean_word_length': 4.503787878787879, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2699073', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1321, 'n_words': 232}