<commit_before># -*- coding: utf-8 -*-
from json import dumps
from django.contrib.gis.shortcuts import render_to_text
from django.core.exceptions import PermissionDenied, MultipleObjectsReturned
from django.db import IntegrityError, ProgrammingError
from django.db.models import Count
from django.shortcuts import render, redirect, get_object_or_404, resolve_url
from django.contrib.auth.decorators import login_required, permission_required
from django.utils import timezone
from django.http import HttpResponse
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _

from tariff_app.models import Tariff
from agent import NasFailedResult, Transmitter, NasNetworkError
from . import forms
from . import models
import mydefs
from devapp.models import Device
from datetime import datetime


@login_required
@mydefs.only_admins
def peoples(request, gid):
    street_id = mydefs.safe_int(request.GET.get('street'))
    if street_id > 0:
        peoples_list = models.Abon.objects.filter(group=gid, street=street_id)
    else:
        peoples_list = models.Abon.objects.filter(group=gid)

    # фильтр
    dr, field = mydefs.order_helper(request)
    if field:
        peoples_list = peoples_list.order_by(field)

    peoples_list = mydefs.pag_mn(request, peoples_list)

    streets = models.AbonStreet.objects.filter(group=gid)

    return render(request, 'abonapp/peoples.html', {
        'peoples': peoples_list,
        'abon_group': get_object_or_404(models.AbonGroup, pk=gid),
        'streets': streets,
        'street_id': street_id,
        'dir': dr,<commit_msg>добавилвывод ключей состояния абонентов по трафику<commit_after># -*- coding: utf-8 -*-
from json import dumps
from django.contrib.gis.shortcuts import render_to_text
from django.core.exceptions import PermissionDenied, MultipleObjectsReturned
from django.db import IntegrityError, ProgrammingError
from django.db.models import Count
from django.shortcuts import render, redirect, get_object_or_404, resolve_url
from django.contrib.auth.decorators import login_required, permission_required
from django.utils import timezone
from django.http import HttpResponse
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _

from statistics.models import getModel
from tariff_app.models import Tariff
from agent import NasFailedResult, Transmitter, NasNetworkError
from . import forms
from . import models
import mydefs
from devapp.models import Device
from datetime import datetime


@login_required
@mydefs.only_admins
def peoples(request, gid):
    street_id = mydefs.safe_int(request.GET.get('street'))
    if street_id > 0:
        peoples_list = models.Abon.objects.filter(group=gid, street=street_id)
    else:
        peoples_list = models.Abon.objects.filter(group=gid)

    StatModel = getModel()

    # фильтр
    dr, field = mydefs.order_helper(request)
    if field:
        peoples_list = peoples_list.order_by(field)

    peoples_list = mydefs.pag_mn(request, peoples_list)
    for abon in peoples_list:
        if abon.ip_address is not None:
            traf = StatModel.objects.traffic_by_ip( abon.ip_address )
            if traf[1] is not None:
                abon.traf = traf[1]
                abon.is_online =traf[0]

    streets = models.AbonStreet.objects.filter(group=gid)

    return render(request, 'abonapp/peoples.html', {
        'peoples': peoples_list,
        'abon_group': get_object_or_404(models.AbonGroup, pk=gid),
        'streets': streets,
        'street_id': street_id,
        'dir': dr,
{'fraction_non_alphanumeric': 0.0812780269058296, 'fraction_numerical': 0.005325112107623318, 'mean_word_length': 4.135251798561151, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2921015', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1095, 'n_words': 277}