<commit_before>angular.module('ukfn')
    .controller('directoryController', function ($http, $localStorage, $sce) {
        // this scope name
        var controller = this;
        controller.$storage = $localStorage;
        controller.searchTerms = []; // terms entered in recorded search box
        controller.loading = true; // flag to display loading message

        controller.initialise = function() {
            controller.clearCache();
            controller.loadUsers();
        }

        controller.updateQuery = function(query) {
            controller.loadUsers();
        };

        controller.clearCache = function () {
            var oneWeekAgo = new Date();
            oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
            if (oneWeekAgo > controller.$storage['directory-date']) {
                controller.$storage.$reset();
            }
        };

        controller.loadUsers = function() {
            var url = '/api/public/users/';
            var query = JSON.stringify(controller.searchTerms);
            var cacheId = url + '*' + query;
            controller.loading = true;
<commit_msg>sort terms to improve performance<commit_after>angular.module('ukfn')
    .controller('directoryController', function ($http, $localStorage, $sce) {
        // this scope name
        var controller = this;
        controller.$storage = $localStorage;
        controller.searchTerms = []; // terms entered in recorded search box
        controller.loading = true; // flag to display loading message

        controller.initialise = function() {
            controller.clearCache();
            controller.loadUsers();
        }

        controller.updateQuery = function(query) {
            controller.loadUsers();
        };

        controller.clearCache = function () {
            var oneWeekAgo = new Date();
            oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
            if (oneWeekAgo > controller.$storage['directory-date']) {
                controller.$storage.$reset();
            }
        };

        controller.loadUsers = function() {
            var url = '/api/public/users/';
            var query = JSON.stringify(controller.searchTerms);
            var cacheId = url + '*' + controller.searchTerms.sort();
            controller.loading = true;

{'fraction_non_alphanumeric': 0.11795316565481354, 'fraction_numerical': 0.0008673026886383347, 'mean_word_length': 2.0235910878112713, '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': '6184656', 'n_tokens_mistral': 569, 'n_tokens_neox': 554, 'n_words': 126}