<commit_before>from core.models import ApplicationBookmark as ImageBookmark
from django.utils import timezone
from django.db.models import Q

from api.v2.serializers.details import ImageBookmarkSerializer
from api.v2.views.base import AuthViewSet
from api.v2.views.mixins import MultipleFieldLookup


class ImageBookmarkViewSet(MultipleFieldLookup, AuthViewSet):

    """
    API endpoint that allows instance actions to be viewed or edited.
    """

    lookup_fields = ("id", "uuid")
    queryset = ImageBookmark.objects.all()
    serializer_class = ImageBookmarkSerializer
    http_method_names = ['get', 'post', 'delete', 'head', 'options', 'trace']

    def perform_create(self, serializer):
        serializer.save(user=self.request.user)

    def get_queryset(self):
        """
        Filter projects by current user
        """
        user = self.request.user
        now_time = timezone.now()
        return ImageBookmark.objects.filter(user=user).filter(
            Q(application__end_date__isnull=True) & Q(application__end_date__gt=now_time)
        )<commit_msg>Fix disappearing image bookmarks on refresh<commit_after>from core.models import ApplicationBookmark as ImageBookmark
from django.utils import timezone
from django.db.models import Q

from api.v2.serializers.details import ImageBookmarkSerializer
from api.v2.views.base import AuthViewSet
from api.v2.views.mixins import MultipleFieldLookup


class ImageBookmarkViewSet(MultipleFieldLookup, AuthViewSet):

    """
    API endpoint that allows instance actions to be viewed or edited.
    """

    lookup_fields = ("id", "uuid")
    queryset = ImageBookmark.objects.all()
    serializer_class = ImageBookmarkSerializer
    http_method_names = ['get', 'post', 'delete', 'head', 'options', 'trace']

    def perform_create(self, serializer):
        serializer.save(user=self.request.user)

    def get_queryset(self):
        """
        Filter projects by current user
        """
        user = self.request.user
        now_time = timezone.now()
        return ImageBookmark.objects.filter(user=user).filter(
            Q(application__end_date__isnull=True) | Q(application__end_date__gt=now_time)
        )
{'fraction_non_alphanumeric': 0.09323583180987204, 'fraction_numerical': 0.002742230347349177, 'mean_word_length': 3.738095238095238, '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': '3602639', 'n_tokens_mistral': 624, 'n_tokens_neox': 609, 'n_words': 151}