<commit_before>from django.contrib.auth.models import User
from django.template import Context, Template, RequestContext
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.db import connection, transaction

def counter(request):
    def q_count(country):
        cursor = connection.cursor()
        cursor.execute("SELECT COUNT(*) FROM pollster_results_intake WHERE \"Qcountry\" = %s", [country])
        row = cursor.fetchone()
        return row[0]

    count = User.objects.count()

    if request.GET.get('country'):
        surely_nl = q_count("NL")
        surely_be = q_count("BE")

        rest = count - surely_nl - surely_be

        if request.GET.get('country') == "NL":
            return HttpResponse(str(surely_nl + int(2/3.0 * rest)))
        if request.GET.get('country') == "BE":
            return HttpResponse(str(surely_be + int(1/3.0 * rest)))

    return HttpResponse(str(count))<commit_msg>Counter shows only this year's intake<commit_after>from django.contrib.auth.models import User
from django.template import Context, Template, RequestContext
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.db import connection, transaction

def counter(request):
    def country_count(country):
        cursor = connection.cursor()
        cursor.execute("SELECT COUNT(*) FROM (SELECT global_id FROM pollster_results_intake WHERE \"Qcountry\" = %s GROUP BY global_id) AS x", [country])
        row = cursor.fetchone()
        return row[0]

    def global_count():
        cursor = connection.cursor()
        cursor.execute("SELECT COUNT(*) FROM (SELECT global_id FROM pollster_results_intake GROUP BY global_id) AS x", [])
        row = cursor.fetchone()
        return row[0]

    try:
        if request.GET.get('country'):
            return HttpResponse(str(country_count(request.GET.get('country'))))

        return HttpResponse(str(global_count()))
    except:
        return HttpResponse('-')
{'fraction_non_alphanumeric': 0.1113873694679264, 'fraction_numerical': 0.0044753853804077575, 'mean_word_length': 3.402625820568928, 'pattern_counts': {'":': 2, '<': 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': '6157503', 'n_tokens_mistral': 568, 'n_tokens_neox': 550, 'n_words': 152}