<commit_before>var API_URL = "http://localhost:3000";

app.models.book = {
    getCollection: function(bookTypeId, bookFormId, bookGenreId) { // argumenty funkcji są pozycyjne (kolejność ma znaczenie!)
        if(bookTypeId) {
            return $.get(API_URL + '/books', {bookTypeId: bookTypeId});
        } else if(bookFormId) {
            return $.get(API_URL + '/books', {bookFormId: bookFormId});
        } else if(bookGenreId) {
            return $.get(API_URL + '/books', {bookGenreId: bookGenreId});
        } else {
            return $.get(API_URL + '/books');
        }
    },
    getItem: function() {
        //...
    },
    createItem: function() {
        //...
    },
    updateItem: function() {
        //...
    },
    deleteItem: function() {
        //...
    }
};

app.models.bookTypes = {
    getCollection: function() {
        return $.get(API_URL + '/bookTypes');
    }
};

app.models.bookForms = {
    getCollection: function() {
        return $.get(API_URL + '/bookForms');
    }
};

app.models.bookGenres = {
    getCollection: function() {
        return $.get(API_URL + '/bookGenres');
    }
};<commit_msg>Caching book forms and book genres<commit_after>var API_URL = "http://localhost:3000";

app.models.book = {
    getCollection: function(bookTypeId, bookFormId, bookGenreId) { // argumenty funkcji są pozycyjne (kolejność ma znaczenie!)
        if(bookTypeId) {
            return $.get(API_URL + '/books', {bookTypeId: bookTypeId});
        } else if(bookFormId) {
            return $.get(API_URL + '/books', {bookFormId: bookFormId});
        } else if(bookGenreId) {
            return $.get(API_URL + '/books', {bookGenreId: bookGenreId});
        } else {
            return $.get(API_URL + '/books');
        }
    },
    getItem: function() {
        //...
    },
    createItem: function() {
        //...
    },
    updateItem: function() {
        //...
    },
    deleteItem: function() {
        //...
    }
};

app.models.bookTypes = {
    getCollection: function() {
        return $.get(API_URL + '/bookTypes');
    }
};

var cachedBookForms;
app.models.bookForms = {
    getCollection: function() {
        if(!cachedBookForms) { // warunek w if-e zawsze zrzuca się do true/false (uwaga na tzw. falsy values);
            // jeśli false, to wykonywany jest else (o ile został określony)
            cachedBookForms = $.get(API_URL + '/bookForms');
        }
        return cachedBookForms;
        // żaden kod po return nie zostanie nigdy wykonany
    }
};

var cachedBookGenres;
app.models.bookGenres = {
    getCollection: function() {
        if(!cachedBookGenres) {
            cachedBookGenres = $.get(API_URL + '/bookGenres');
        }
        return cachedBookGenres;
    }
};
{'fraction_non_alphanumeric': 0.1535935789857716, 'fraction_numerical': 0.002918642831083546, 'mean_word_length': 2.1053227633069085, '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': '6549201', 'n_tokens_mistral': 895, 'n_tokens_neox': 893, 'n_words': 176}