<commit_before>/*global angular */
/*jshint -W083 */
(function () {
    'use strict';
    /**
     * Transaction Factory submodule
     *
     * @module TransactionFactory.factory
     */
    angular.module('TransactionFactory.factory', [])
    /**
     * TransactionFactory is a factory that handles the transactional interactions with the IndexedDb database
     *
     * @namespace TransactionFactory.factory
     * @class TransactionFactory
     * @constructor
     * @param ConnectionManager The ConnectionManager factory that handles connecting to the IndexedDb instance
     */
    .factory('TransactionFactory', ['$q', 'ConnectionManager',
            function ($q, ConnectionManager) {
            var clearDataFromObjectStore;
            clearDataFromObjectStore = function (databaseObject, objectStoreName) {
                databaseObject.Db.transaction([objectStoreName])
                    .objectStore(objectStoreName).clear();
            };
            return {
                /**
                 * Insert a record or collection of records into the specified object store
                 * @public
                 * @method insert
                 * @param {Object} databaseObject The name and properties of the database
                 * @param {Object} objectStoreObject The name and properties of the object store
                 * @param {Object} indecesObject The name and properties of the indeces object
                 * @param {Object} itemsToAdd An array of any type of the records to add
                 */
                insert: function (databaseObject, objectStoreObject, indecesObject, itemsToAdd) {
                    var callback, store;
                    callback = function (databaseObject, objectStore) {
                        var item, transaction;
                        for (item in itemsToAdd) {
                            if (itemsToAdd.hasOwnProperty(item)) {
                                transaction = databaseObject.Db.transaction([objectStore.name], 'readwrite');
                                if (itemsToAdd.hasOwnProperty(item)) {
                                    if (objectStore.createdObjectStore !== null) {
                                        transaction.add(itemsToAdd[item]);
                                    } else {
                                        store = transaction.objectStore(objectStore.name);
                                        store.add(itemsToAdd[item]);
                                    }
                                }
                            }
                        }
                    };
                    ConnectionManager.openConnection(databaseObject, objectStoreObject, indecesObject, callback);
                },
                /**
                 * Insert a record or collection of records into the specified object store
                 * @public
                 * @method insertWithPromise
                 * @param {Object} databaseObject The name and properties of the database
                 * @param {Object} objectStoreObject The name and properties of the object store
                 * @param {Object} indecesObject The name and properties of the indeces object
                 * @param {Object} itemsToAdd An array of any type of the records to add
                 *
                 * @return {Boolean} $q.promise Return true if function completes successfully
                 */
                insertWithPromise: function (databaseObject, objectStoreObject, indecesObject, itemsToAdd) {
                    var deferred, store;
                    deferred = $q.defer();
                    ConnectionManager.openConnectionWithPromise(databaseObject, objectStoreObject, indecesObject)
                        .then(function (data) {
                        var item, transaction;
                        for (item in itemsToAdd) {
                            if (itemsToAdd.hasOwnProperty(item)) {
                                transaction = data.transaction([objectStoreObject.name], 'readwrite');
                                if (itemsToAdd.hasOwnProperty(item)) {
                                    if (objectStoreObject.createdObjectStore !== null) {
                                        transaction.add(itemsToAdd[item]);
                                    } else {
                                        store = transaction.objectStore(objectStoreObject.name);
                                        store.add(itemsToAdd[item]);
                                    }
                                }
                            }
                            deferred.resolve(true);
                        }
                    });
                    return deferred.promise;
                },
                /**
                 * Delete the specified record from the database
                 * @public
                 * @method delete
                 * @param {Object} databaseObject The name and properties of the database
                 * @param {Object} objectStoreObject The name and properties of the object store
                 * @param {Object} indecesObject The name and properties of the indeces object
                 * @param {String or Number} keyToDelete The key value of the record to delete
                 */<commit_msg>Updating a broken section of transaction code.<commit_after>/*global angular */
/*jshint -W083 */
(function () {
    'use strict';
    /**
     * Transaction Factory submodule
     *
     * @module TransactionFactory.factory
     */
    angular.module('TransactionFactory.factory', [])
    /**
     * TransactionFactory is a factory that handles the transactional interactions with the IndexedDb database
     *
     * @namespace TransactionFactory.factory
     * @class TransactionFactory
     * @constructor
     * @param ConnectionManager The ConnectionManager factory that handles connecting to the IndexedDb instance
     */
    .factory('TransactionFactory', ['$q', 'ConnectionManager',
            function ($q, ConnectionManager) {
            var clearDataFromObjectStore;
            clearDataFromObjectStore = function (databaseObject, objectStoreName) {
                databaseObject.Db.transaction([objectStoreName])
                    .objectStore(objectStoreName).clear();
            };
            return {
                /**
                 * Insert a record or collection of records into the specified object store
                 * @public
                 * @method insert
                 * @param {Object} databaseObject The name and properties of the database
                 * @param {Object} objectStoreObject The name and properties of the object store
                 * @param {Object} indecesObject The name and properties of the indeces object
                 * @param {Object} itemsToAdd An array of any type of the records to add
                 */
                insert: function (databaseObject, objectStoreObject, indecesObject, itemsToAdd) {
                    var callback, store;
                    callback = function (databaseObject, objectStore) {
                        var item, transaction;
                        for (item in itemsToAdd) {
                            if (itemsToAdd.hasOwnProperty(item)) {
                                transaction = databaseObject.Db.transaction([objectStore.name], 'readwrite');
                                if (itemsToAdd.hasOwnProperty(item)) {
                                    if (objectStore.createdObjectStore !== null) {
                                        transaction.add(itemsToAdd[item]);
                                    } else {
                                        store = transaction.objectStore(objectStore.name);
                                        store.add(itemsToAdd[item]);
                                    }
                                }
                            }
                        }
                    };
                    ConnectionManager.openConnection(databaseObject, objectStoreObject, indecesObject, callback);
                },
                /**
                 * Insert a record or collection of records into the specified object store
                 * @public
                 * @method insertWithPromise
                 * @param {Object} databaseObject The name and properties of the database
                 * @param {Object} objectStoreObject The name and properties of the object store
                 * @param {Object} indecesObject The name and properties of the indeces object
                 * @param {Object} itemsToAdd An array of any type of the records to add
                 *
                 * @return {Boolean} $q.promise Return true if function completes successfully
                 */
                insertWithPromise: function (databaseObject, objectStoreObject, indecesObject, itemsToAdd) {
                    var deferred, store;
                    deferred = $q.defer();
                    ConnectionManager.openConnectionWithPromise(databaseObject, objectStoreObject, indecesObject)
                        .then(function (data) {
                        var item, transaction;
                        for (item in itemsToAdd) {
                            if (itemsToAdd.hasOwnProperty(item)) {
                                transaction = data.transaction([objectStoreObject.name], 'readwrite');
                                if (itemsToAdd.hasOwnProperty(item)) {
                                    if (objectStoreObject.createdObjectStore !== null && objectStoreObject.createdObjectStore !== null) {
                                        objectStoreObject.createdObjectStore.add(itemsToAdd[item]);
                                    } else {
                                        store = transaction.objectStore(objectStoreObject.name);
                                        store.add(itemsToAdd[item]);
                                    }
                                }
                            }
                            deferred.resolve(true);
                        }
                    });
                    return deferred.promise;
                },
                /**
                 * Delete the specified record from the database
                 * @public
                 * @method delete
                 * @param {Object} databaseObject The name and properties of the database
                 * @param {Object} objectStoreObject The name and properties of the object store
                 * @param {Object} indecesObject The name and properties of the indeces object
                 * @param {String or Number} keyToDelete The key value of the record to delete
                 */
{'fraction_non_alphanumeric': 0.067440780306549, 'fraction_numerical': 0.000557361820715281, 'mean_word_length': 1.3132788998710787, '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': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6254738', 'n_tokens_mistral': 2140, 'n_tokens_neox': 2063, 'n_words': 652}