<commit_before>'use strict';

var app = angular.module('bens-penhorados');

app.controller('VehicleListCtrl', ['$scope', '$location', 'Vehicle', 'VehicleFilters', function($scope, $location, Vehicle, VehicleFilters) {
    $scope.items = [];
    $scope.totalItems = 0;
    $scope.itemsFrom = 0;
    $scope.itemsTo = 0;
    $scope.itemsPerPageValues = [5, 15, 25, 50, 100];

    init();

    var $toWatch = [
        'filterMake',
        'filterModel',
        'filterCategory',
        'filterType',
        'itemsPerPage'
    ];

    $scope.$watchGroup($toWatch, function(newValues, oldValues, scope) {
        if (!angular.equals(newValues, oldValues)) {
            setSearchVars(1);
        }
    });

    function init() {
        var search = $location.search();
        $scope.pagination = {
            current: search.page === undefined ? 1 : search.page,
        };
        $scope.itemsPerPage = search.limit === undefined ? 5 : parseInt(search.limit);
        $scope.filterMake = search.make;
        $scope.filterModel = search.model;
        $scope.filterCategory = search.category;
        $scope.filterType = search.type;

        getResultsPage($scope.pagination.current);
        getFilteringAttributes();
    }

    function setSearchVars(pageNumber) {
        $location.search({
            page: pageNumber,
            limit: $scope.itemsPerPage,
            make: $scope.filterMake,
            model: $scope.filterModel,
            category: $scope.filterCategory,
            type: $scope.filterType,
        });
    }

    function getResultsPage(pageNumber) {
        Vehicle.query({
            page: pageNumber,
            limit: $scope.itemsPerPage,
            make: $scope.filterMake,
            model: $scope.filterModel,
            category: $scope.filterCategory,
            type: $scope.filterType,
        }, function(data) {
            $scope.result = data;
            $scope.noResults = ((data.items.length) ? false : true);
        }, function(error) {});
    }

    function getFilteringAttributes() {
        VehicleFilters.query({
            make: $scope.filterMake,
        }, function(data) {
            $scope.filteringAttr = data;
        }, function(error) {});<commit_msg>Search by district/municipality<commit_after>'use strict';

var app = angular.module('bens-penhorados');

app.controller('VehicleListCtrl', ['$scope', '$location', 'Vehicle', 'VehicleFilters', function($scope, $location, Vehicle, VehicleFilters) {
    $scope.items = [];
    $scope.totalItems = 0;
    $scope.itemsFrom = 0;
    $scope.itemsTo = 0;
    $scope.itemsPerPageValues = [5, 15, 25, 50, 100];

    init();

    var $toWatch = [
        'filterMake',
        'filterModel',
        'filterCategory',
        'filterType',
        'filterDistrict',
        'filterMunicipality',
        'itemsPerPage'
    ];

    $scope.$watchGroup($toWatch, function(newValues, oldValues, scope) {
        if (!angular.equals(newValues, oldValues)) {
            setSearchVars(1);
        }
    });

    function init() {
        var search = $location.search();
        $scope.pagination = {
            current: search.page === undefined ? 1 : search.page,
        };
        $scope.itemsPerPage = search.limit === undefined ? 5 : parseInt(search.limit);
        $scope.filterDistrict = search.district;
        $scope.filterMunicipality = search.municipality;
        $scope.filterMake = search.make;
        $scope.filterModel = search.model;
        $scope.filterCategory = search.category;
        $scope.filterType = search.type;

        getResultsPage($scope.pagination.current);
        getFilteringAttributes();
    }

    function setSearchVars(pageNumber) {
        $location.search({
            page: pageNumber,
            limit: $scope.itemsPerPage,
            district: $scope.filterDistrict,
            municipality: $scope.filterMunicipality,
            make: $scope.filterMake,
            model: $scope.filterModel,
            category: $scope.filterCategory,
            type: $scope.filterType,
        });
    }

    function getResultsPage(pageNumber) {
        Vehicle.query({
            page: pageNumber,
            limit: $scope.itemsPerPage,
            district: $scope.filterDistrict,
            municipality: $scope.filterMunicipality,
            make: $scope.filterMake,
            model: $scope.filterModel,
            category: $scope.filterCategory,
            type: $scope.filterType,
        }, function(data) {
            $scope.result = data;
            $scope.noResults = ((data.items.length) ? false : true);
        }, function(error) {});
    }

    function getFilteringAttributes() {
        VehicleFilters.query({
            make: $scope.filterMake,
        }, function(data) {
            $scope.filteringAttr = data;
        }, function(error) {});
{'fraction_non_alphanumeric': 0.1321886636326024, 'fraction_numerical': 0.006619776582540339, 'mean_word_length': 2.1809210526315788, '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': '5926195', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1364, 'n_words': 248}