<commit_before>(function() {

    'use strict';

    angular
        .module('openlmis-core')
        .factory('localStorageFactory', factory);

    factory.$inject = ['localStorageService', '$filter'];

    function factory(localStorageService, $filter) {
        var resources = {};

        return LocalStorageFactory;

        function LocalStorageFactory(resourceName) {
            if (resources[resourceName]) {
                return resources[resourceName];
            }

            var items = getFromStorage(resourceName);
            if (!items) {
                items = [];
            }

            var resource = {
                put: put,
                getBy: getBy,
                getAll: getAll,
                search: search,
                removeBy: removeBy,
                clearAll: clearAll,
                contains: contains
            };
            resources[resourceName] = resource;
            return resource;

            function put(object) {
                executeWithStorageUpdate(function() {
                    if (object.id) {
                        removeItemBy('id', object.id);
                    }
                    items.push(copy(object));
                });
            }

            function getBy(property, value) {
                var filtered = searchItems(toParams(property, value));
                return filtered.length ? copy(filtered[0]) : undefined;
            }

            function getAll() {
                return copyList(items);
            }

            function search(params, filter) {
                return copyList(searchItems(params, filter));
            }
<commit_msg>OLMIS-1339: Fixed issue with Available Offline flag<commit_after>(function() {

    'use strict';

    angular
        .module('openlmis-core')
        .factory('localStorageFactory', factory);

    factory.$inject = ['localStorageService', '$filter'];

    function factory(localStorageService, $filter) {
        var resources = {};

        return LocalStorageFactory;

        function LocalStorageFactory(resourceName) {
            if (resources[resourceName]) {
                return resources[resourceName];
            }

            var items = getFromStorage(resourceName);
            if (!items) {
                items = [];
            }

            var resource = {
                put: put,
                getBy: getBy,
                getAll: getAll,
                search: search,
                removeBy: removeBy,
                clearAll: clearAll,
                contains: contains
            };
            resources[resourceName] = resource;
            return resource;

            function put(item) {
                if (item && !contains(item)) {
                    executeWithStorageUpdate(function() {
                        if (item.id) {
                            removeItemBy('id', item.id);
                        }
                        items.push(typeof item === 'object' ? copy(item) : item);
                    });
                }

            }

            function getBy(property, value) {
                var filtered = searchItems(toParams(property, value));
                return filtered.length ? copy(filtered[0]) : undefined;
            }

            function getAll() {
                return copyList(items);
            }

            function search(params, filter) {
                return copyList(searchItems(params, filter));
            }

{'fraction_non_alphanumeric': 0.09655172413793103, 'fraction_numerical': 0.0017241379310344827, 'mean_word_length': 1.3114209827357237, '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': '1880464', 'n_tokens_mistral': 833, 'n_tokens_neox': 763, 'n_words': 169}