@require_GET
@json_response
def thread_info(request):
    domain = request.GET.get('domain', None)
    thread_url = request.GET.get('thread', None)
    titles = {
        'selector_title': request.GET.get('selector_title', ""),
        'page_title': request.GET.get('page_title', ""),
        'h1_title': request.GET.get('h1_title', "")
    }

    try:
        site = Site.objects.get(domain=domain)
    except Site.DoesNotExist:
        return HttpResponseBadRequest(
            domain % 'site with domain %s not found'
        )

    thread, created = site.threads.get_or_create(url=thread_url)
    thread.titles = titles
    thread.save()

    if request.session.get('all_comments'):
        del request.session['all_comments']

    # add random avatar to session if anonymous
    avatar_num = request.session.get("user_avatar_num", None)

    if not avatar_num and request.user.is_anonymous():
        avatar_num = random.randint(
            settings.AVATAR_NUM_MIN,
            settings.AVATAR_NUM_MAX
        )
        request.session['user_avatar_num'] = avatar_num

    return {
        "thread_id": thread.id,
        "comments_enabled": thread.allow_comments,
        "spellcheck_enabled": settings.SPELLCHECK_ENABLED,
        "spellcheck_localization": SPELLCHECK_LOCALIZATION
    }
dataset/ETHPy150Open c4all/c4all/comments/views.py/thread_info/swapped operands of `%`